Run clang-format on legacy code

This commit is contained in:
Louis Gombert
2024-06-15 20:13:59 +02:00
parent 86cce1e445
commit 5372e01323
120 changed files with 18536 additions and 20338 deletions

View File

@@ -115,83 +115,72 @@ int Num_d2d_devices = 0;
int Num_d3d_devices = 0;
// The enumeration callback for D3D devices
HRESULT WINAPI gr_d3d_enum( LPGUID lpGUID,
LPSTR lpDeviceDescription,
LPSTR lpDeviceName,
LPD3DDEVICEDESC lpHWDesc,
LPD3DDEVICEDESC lpHELDesc,
LPVOID lpContext )
{
HRESULT WINAPI gr_d3d_enum(LPGUID lpGUID, LPSTR lpDeviceDescription, LPSTR lpDeviceName, LPD3DDEVICEDESC lpHWDesc,
LPD3DDEVICEDESC lpHELDesc, LPVOID lpContext) {
int use_it = 0;
// mprintf( "Found 3d device %s: %s\n", lpDeviceName, lpDeviceDescription );
// mprintf( "Found 3d device %s: %s\n", lpDeviceName, lpDeviceDescription );
if ( lpHWDesc && lpHWDesc->dwFlags != 0 ) {
if (lpHWDesc && lpHWDesc->dwFlags != 0) {
use_it = 1;
} //else if ( lpHELDesc ) {
} // else if ( lpHELDesc ) {
if ( use_it ) {
if (use_it) {
d3d_device *d2d = (d3d_device *)lpContext;
d3d_device *d3d = (d3d_device *)&D3D_devices[Num_d3d_devices++];
if ( lpGUID ) {
memmove( &d3d->guid_3d, lpGUID, sizeof(GUID) );
if (lpGUID) {
memmove(&d3d->guid_3d, lpGUID, sizeof(GUID));
d3d->pguid_3d = &d3d->guid_3d;
} else {
memset( &d3d->guid_3d, 0, sizeof(GUID) );
memset(&d3d->guid_3d, 0, sizeof(GUID));
d3d->pguid_3d = NULL;
}
memmove( &d3d->guid_2d, &d2d->guid_2d, sizeof(GUID) );
if ( d2d->pguid_2d ) {
memmove(&d3d->guid_2d, &d2d->guid_2d, sizeof(GUID));
if (d2d->pguid_2d) {
d3d->pguid_2d = &d3d->guid_2d;
} else {
d3d->pguid_2d = NULL;
}
//strcpy( d3d->name, "Direct 3D - " );
strcpy( d3d->name, d2d->name );
// strcpy( d3d->name, "Direct 3D - " );
strcpy(d3d->name, d2d->name);
}
return D3DENUMRET_OK;
}
// The enumeration callback for 2D
BOOL WINAPI gr_d2d_enum( LPGUID lpGUID,
LPSTR lpDeviceDescription,
LPSTR lpDeviceName,
LPVOID lpContext )
{
BOOL WINAPI gr_d2d_enum(LPGUID lpGUID, LPSTR lpDeviceDescription, LPSTR lpDeviceName, LPVOID lpContext) {
d3d_device *d2d = (d3d_device *)&D2D_devices[Num_d2d_devices++];
// mprintf( "Found 2d device %s: %s\n", lpDeviceName, lpDeviceDescription );
// mprintf( "Found 2d device %s: %s\n", lpDeviceName, lpDeviceDescription );
if ( lpGUID ) {
memmove( &d2d->guid_2d, lpGUID, sizeof(GUID) );
if (lpGUID) {
memmove(&d2d->guid_2d, lpGUID, sizeof(GUID));
d2d->pguid_2d = &d2d->guid_2d;
} else {
memset( &d2d->guid_2d, 0, sizeof(GUID) );
memset(&d2d->guid_2d, 0, sizeof(GUID));
d2d->pguid_2d = NULL;
}
strcpy( d2d->name, lpDeviceDescription );
// strcat( d2d->name, lpDeviceName );
strcpy(d2d->name, lpDeviceDescription);
// strcat( d2d->name, lpDeviceName );
return D3DENUMRET_OK;
}
HRESULT (__stdcall *pfn_DirectDrawEnumerate) (LPDDENUMCALLBACK, LPVOID) = NULL;
HRESULT (__stdcall *pfn_DirectDrawCreate) (GUID FAR *, LPDIRECTDRAW FAR *, IUnknown FAR *) = NULL;
HRESULT(__stdcall *pfn_DirectDrawEnumerate)(LPDDENUMCALLBACK, LPVOID) = NULL;
HRESULT(__stdcall *pfn_DirectDrawCreate)(GUID FAR *, LPDIRECTDRAW FAR *, IUnknown FAR *) = NULL;
// Check for any Direct 3D devices
void check_direct3d()
{
void check_direct3d() {
int i;
HRESULT ddrval;
LPDIRECTDRAW lpDD1=NULL;
LPDIRECT3D2 lpD3D=NULL;
LPDIRECTDRAW lpDD1 = NULL;
LPDIRECT3D2 lpD3D = NULL;
Num_d2d_devices = 0;
Num_d3d_devices = 0;
@@ -200,39 +189,41 @@ void check_direct3d()
return;
if (!pfn_DirectDrawCreate)
pfn_DirectDrawCreate = (HRESULT (__stdcall *) (GUID FAR *, LPDIRECTDRAW FAR *, IUnknown FAR *)) GetProcAddress(Dd_dll_handle, "DirectDrawCreate");
pfn_DirectDrawCreate = (HRESULT(__stdcall *)(GUID FAR *, LPDIRECTDRAW FAR *, IUnknown FAR *))GetProcAddress(
Dd_dll_handle, "DirectDrawCreate");
if (!pfn_DirectDrawCreate)
goto D3DError;
if (!pfn_DirectDrawEnumerate)
pfn_DirectDrawEnumerate = (HRESULT (__stdcall *) (LPDDENUMCALLBACK, LPVOID)) GetProcAddress(Dd_dll_handle, "DirectDrawEnumerateA");
pfn_DirectDrawEnumerate =
(HRESULT(__stdcall *)(LPDDENUMCALLBACK, LPVOID))GetProcAddress(Dd_dll_handle, "DirectDrawEnumerateA");
if (!pfn_DirectDrawEnumerate)
goto D3DError;
ddrval = pfn_DirectDrawEnumerate( gr_d2d_enum, NULL );
if ( ddrval != DD_OK ) {
OutputDebugString( "GR_D3D_INIT: DirectDrawEnumerate failed.\n" );
ddrval = pfn_DirectDrawEnumerate(gr_d2d_enum, NULL);
if (ddrval != DD_OK) {
OutputDebugString("GR_D3D_INIT: DirectDrawEnumerate failed.\n");
goto D3DError;
}
for ( i=0; i<Num_d2d_devices; i++) {
for (i = 0; i < Num_d2d_devices; i++) {
d3d_device *d2d = (d3d_device *)&D2D_devices[i];
ddrval = pfn_DirectDrawCreate( d2d->pguid_2d, &lpDD1, NULL );
if ( ddrval != DD_OK ) {
OutputDebugString( "GR_D3D_INIT: DirectDrawCreate failed.\n" );
ddrval = pfn_DirectDrawCreate(d2d->pguid_2d, &lpDD1, NULL);
if (ddrval != DD_OK) {
OutputDebugString("GR_D3D_INIT: DirectDrawCreate failed.\n");
goto D3DError;
}
ddrval = lpDD1->QueryInterface( IID_IDirect3D2, ( LPVOID *) &lpD3D );
if ( ddrval != DD_OK ) {
OutputDebugString( "GR_D3D_INIT: QueryInterface failed.\n" );
ddrval = lpDD1->QueryInterface(IID_IDirect3D2, (LPVOID *)&lpD3D);
if (ddrval != DD_OK) {
OutputDebugString("GR_D3D_INIT: QueryInterface failed.\n");
goto D3DError;
}
ddrval = lpD3D->EnumDevices(gr_d3d_enum, d2d );
if ( ddrval != DD_OK ) {
OutputDebugString( "WIN_DD32: D3D enum devices failed. (0x%x)\n");//, ddrval );
ddrval = lpD3D->EnumDevices(gr_d3d_enum, d2d);
if (ddrval != DD_OK) {
OutputDebugString("WIN_DD32: D3D enum devices failed. (0x%x)\n"); //, ddrval );
}
lpD3D->Release();
@@ -243,9 +234,9 @@ void check_direct3d()
}
// Store Direct3D devices in number of cards
for ( i=0; i<Num_d3d_devices; i++) {
strcpy( Cards[Num_cards].name, D3D_devices[i].name );
Cards[Num_cards].renderer_type=RENDERER_DIRECT3D;
for (i = 0; i < Num_d3d_devices; i++) {
strcpy(Cards[Num_cards].name, D3D_devices[i].name);
Cards[Num_cards].renderer_type = RENDERER_DIRECT3D;
Num_cards++;
}
@@ -254,27 +245,26 @@ void check_direct3d()
D3DError:
// If any devices haven't been freed, free them
if(lpD3D!=NULL) {
if (lpD3D != NULL) {
lpD3D->Release();
lpD3D = NULL;
}
if(lpDD1!=NULL) {
if (lpDD1 != NULL) {
lpDD1->Release();
lpDD1 = NULL;
}
//mprintf( "Direct3D Polling failed.\n" );
// mprintf( "Direct3D Polling failed.\n" );
return;
}
void check_glide()
{
void check_glide() {
static GrHwConfiguration hwconfig;
module *GlideDLLHandle;
if ( !(GlideDLLHandle=LoadGlideDLL()) ) {
//mprintf( "Glide DLL not found!\n" );
if (!(GlideDLLHandle = LoadGlideDLL())) {
// mprintf( "Glide DLL not found!\n" );
return;
}
@@ -282,18 +272,17 @@ void check_glide()
// Check if any 3dfx systems are present
grSstQueryBoards(&hwconfig);
if(hwconfig.num_sst<=0) {
if (hwconfig.num_sst <= 0) {
mod_FreeModule(GlideDLLHandle);
return;
}
grGlideInit();
GlideInited=TRUE;
GlideInited = TRUE;
if (grSstQueryHardware(&hwconfig)==0 || hwconfig.num_sst<1)
{
if (grSstQueryHardware(&hwconfig) == 0 || hwconfig.num_sst < 1) {
// Glide is now only shutdown when the application exits
//grGlideShutdown();
// grGlideShutdown();
mod_FreeModule(GlideDLLHandle);
return;
}
@@ -301,46 +290,45 @@ void check_glide()
grGlideShutdown();
}
if(hwconfig.num_sst<=0) {
if (hwconfig.num_sst <= 0) {
mod_FreeModule(GlideDLLHandle);
return;
}
Cards[Num_cards].renderer_type=RENDERER_GLIDE;
Cards[Num_cards].renderer_type = RENDERER_GLIDE;
switch(hwconfig.SSTs[0].type) {
switch (hwconfig.SSTs[0].type) {
case GR_SSTTYPE_VOODOO:
#if (defined(OEM_VOODOO3) && !defined(USE_ALL_VIDEO_OPTIONS))
strcpy( Cards[Num_cards].name, "Voodoo3" );
strcpy(Cards[Num_cards].name, "Voodoo3");
#else
strcpy( Cards[Num_cards].name, "Voodoo Graphics Family" );
strcpy(Cards[Num_cards].name, "Voodoo Graphics Family");
#endif
break;
case GR_SSTTYPE_SST96:
strcpy( Cards[Num_cards].name, "SST96" );
strcpy(Cards[Num_cards].name, "SST96");
break;
case GR_SSTTYPE_AT3D:
strcpy( Cards[Num_cards].name, "AT3D" );
strcpy(Cards[Num_cards].name, "AT3D");
break;
default:
strcpy( Cards[Num_cards].name, "" );
strcpy(Cards[Num_cards].name, "");
break;
}
Num_cards++;
// Glide is now only shutdown when the application exits
//grGlideShutdown();
// grGlideShutdown();
mod_FreeModule(GlideDLLHandle);
}
// Shuts down glide (if it has been initialized)
void shutdown_glide(void)
{
if(GlideInited) {
void shutdown_glide(void) {
if (GlideInited) {
module *GlideDLLHandle;
if ( (GlideDLLHandle=LoadGlideDLL()) ) {
if ((GlideDLLHandle = LoadGlideDLL())) {
grGlideShutdown();
mod_FreeModule(GlideDLLHandle);
}
@@ -348,41 +336,39 @@ void shutdown_glide(void)
}
// OpenGL function pointer type definitions
typedef const GLubyte *(CALLBACK* LPFN_GLGETSTRING)(GLenum);
typedef BOOL (CALLBACK *LPFN_WGLMAKECURRENT)(HDC, HGLRC);
typedef HGLRC (CALLBACK *LPFN_WGLCREATECONTEXT)(HDC);
typedef BOOL (CALLBACK *LPFN_WGLDELETECONTEXT)(HGLRC);
typedef const GLubyte *(CALLBACK *LPFN_GLGETSTRING)(GLenum);
typedef BOOL(CALLBACK *LPFN_WGLMAKECURRENT)(HDC, HGLRC);
typedef HGLRC(CALLBACK *LPFN_WGLCREATECONTEXT)(HDC);
typedef BOOL(CALLBACK *LPFN_WGLDELETECONTEXT)(HGLRC);
// Check for OpenGL support, and add it to list
void check_openGL()
{
LPFN_GLGETSTRING pfn_glGetString=NULL;
LPFN_WGLMAKECURRENT pfn_wglMakeCurrent=NULL;
LPFN_WGLCREATECONTEXT pfn_wglCreateContext=NULL;
LPFN_WGLDELETECONTEXT pfn_wglDeleteContext=NULL;
void check_openGL() {
LPFN_GLGETSTRING pfn_glGetString = NULL;
LPFN_WGLMAKECURRENT pfn_wglMakeCurrent = NULL;
LPFN_WGLCREATECONTEXT pfn_wglCreateContext = NULL;
LPFN_WGLDELETECONTEXT pfn_wglDeleteContext = NULL;
// Check for the OpenGL dll, and open it
if(opengl_dll_handle==NULL) {
opengl_dll_handle=LoadLibrary("opengl32.dll");
if(opengl_dll_handle==NULL) {
if (opengl_dll_handle == NULL) {
opengl_dll_handle = LoadLibrary("opengl32.dll");
if (opengl_dll_handle == NULL) {
OutputDebugString("OpenGL DLL not found.\n");
return;
}
}
// Get the functions to check the OpenGL renderer
pfn_glGetString = (LPFN_GLGETSTRING)GetProcAddress(opengl_dll_handle,"glGetString");
pfn_wglCreateContext = (LPFN_WGLCREATECONTEXT)GetProcAddress(opengl_dll_handle,"wglCreateContext");
pfn_wglDeleteContext = (LPFN_WGLDELETECONTEXT)GetProcAddress(opengl_dll_handle,"wglDeleteContext");
pfn_wglMakeCurrent = (LPFN_WGLMAKECURRENT)GetProcAddress(opengl_dll_handle,"wglMakeCurrent");
if (!pfn_glGetString || !pfn_wglCreateContext ||
!pfn_wglDeleteContext || !pfn_wglMakeCurrent) {
pfn_glGetString = (LPFN_GLGETSTRING)GetProcAddress(opengl_dll_handle, "glGetString");
pfn_wglCreateContext = (LPFN_WGLCREATECONTEXT)GetProcAddress(opengl_dll_handle, "wglCreateContext");
pfn_wglDeleteContext = (LPFN_WGLDELETECONTEXT)GetProcAddress(opengl_dll_handle, "wglDeleteContext");
pfn_wglMakeCurrent = (LPFN_WGLMAKECURRENT)GetProcAddress(opengl_dll_handle, "wglMakeCurrent");
if (!pfn_glGetString || !pfn_wglCreateContext || !pfn_wglDeleteContext || !pfn_wglMakeCurrent) {
OutputDebugString("Could not obtain pfn_glGetString().\n");
return;
}
// Make sure the video tab has been initialized first
if(CurrentVideoTab==NULL) {
if (CurrentVideoTab == NULL) {
OutputDebugString("The Video Tab was not set.\n");
return;
}
@@ -393,7 +379,7 @@ void check_openGL()
// destroyed afterwords - this function will fail if
// it is called in any other context.
HDC hOpenGLDC = GetDC(CurrentVideoTab->m_MsgDlg.m_hWnd);
if(hOpenGLDC==NULL) {
if (hOpenGLDC == NULL) {
OutputDebugString("GetDC() failed.\n");
return;
}
@@ -408,33 +394,30 @@ void check_openGL()
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_GENERIC_ACCELERATED;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 16;
pfd.cDepthBits =16;
pfd.cDepthBits = 16;
// Find the user's "best match" PFD
pf = ChoosePixelFormat(hOpenGLDC, &pfd);
if (pf == 0)
{
if (pf == 0) {
OutputDebugString("ChoosePixelFormat() failed.\n");
return;
}
// Try and set the new PFD
if (SetPixelFormat(hOpenGLDC, pf, &pfd) == FALSE)
{
DWORD ret=GetLastError();
if (SetPixelFormat(hOpenGLDC, pf, &pfd) == FALSE) {
DWORD ret = GetLastError();
OutputDebugString("SetPixelFormat() failed.\n");
return;
}
// Get a copy of the newly set PFD
if(DescribePixelFormat(hOpenGLDC, pf, sizeof(PIXELFORMATDESCRIPTOR), &pfd_copy)==0)
{
if (DescribePixelFormat(hOpenGLDC, pf, sizeof(PIXELFORMATDESCRIPTOR), &pfd_copy) == 0) {
OutputDebugString("DescribePixelFormat() failed.\n");
return;
}
// Check the returned PFD to see if it is hardware accelerated
if((pfd_copy.dwFlags & PFD_GENERIC_ACCELERATED)==0 && (pfd_copy.dwFlags & PFD_GENERIC_FORMAT)!=0) {
if ((pfd_copy.dwFlags & PFD_GENERIC_ACCELERATED) == 0 && (pfd_copy.dwFlags & PFD_GENERIC_FORMAT) != 0) {
OutputDebugString("Returned OpenGL device is not hardware accelerated.\n");
return;
}
@@ -442,87 +425,88 @@ void check_openGL()
// Create an OpenGL context, and make it the current context
HGLRC ResourceContext;
ResourceContext = pfn_wglCreateContext((HDC)hOpenGLDC);
if(ResourceContext==NULL) {
DWORD ret=GetLastError();
if (ResourceContext == NULL) {
DWORD ret = GetLastError();
OutputDebugString("wglCreateContext() failed.\n");
return;
}
pfn_wglMakeCurrent((HDC)hOpenGLDC, ResourceContext);
// Add the OpenGL type to card list
Cards[Num_cards].renderer_type=RENDERER_OPENGL;
sprintf(Cards[Num_cards].name,"%s",pfn_glGetString(GL_RENDERER));
Cards[Num_cards].renderer_type = RENDERER_OPENGL;
sprintf(Cards[Num_cards].name, "%s", pfn_glGetString(GL_RENDERER));
Num_cards++;
// Clean up
pfn_wglMakeCurrent(NULL, NULL);
pfn_wglDeleteContext(ResourceContext);
ReleaseDC(CurrentVideoTab->m_hWnd,hOpenGLDC);
ReleaseDC(CurrentVideoTab->m_hWnd, hOpenGLDC);
}
// Fills in Cards and Num_cards
void detect_3dcards(int detect_direct3d, int detect_glide, int detect_opengl)
{
if(VideoCardsDetected) return;
void detect_3dcards(int detect_direct3d, int detect_glide, int detect_opengl) {
if (VideoCardsDetected)
return;
Num_cards = 0;
//CString no_3d_msg;
//no_3d_msg.LoadString(IDS_3D_DETECT_NO3D);
//strcpy( Cards[Num_cards++].name, no_3d_msg );
// CString no_3d_msg;
// no_3d_msg.LoadString(IDS_3D_DETECT_NO3D);
// strcpy( Cards[Num_cards++].name, no_3d_msg );
// Put in the "none" option
Cards[Num_cards].renderer_type=RENDERER_NONE;
strcpy(Cards[Num_cards].name,"");
Cards[Num_cards].renderer_type = RENDERER_NONE;
strcpy(Cards[Num_cards].name, "");
Num_cards++;
// Check for the other types
if(detect_opengl) check_openGL();
if(detect_glide) check_glide();
if(detect_direct3d) check_direct3d();
if (detect_opengl)
check_openGL();
if (detect_glide)
check_glide();
if (detect_direct3d)
check_direct3d();
//VideoCardsDetected=TRUE;
// VideoCardsDetected=TRUE;
}
// Creates a string suitable for the list box
// (combines the renderer_type and the device name)
char *GetFullName(card3d *card)
{
char *GetFullName(card3d *card) {
static char name[1024];
CString temp;
// empty out the name
strcpy(name,"");
strcpy(name, "");
// Copy the renderer type in
switch(card->renderer_type) {
switch (card->renderer_type) {
case RENDERER_SOFTWARE_8BIT:
strcpy(name,"Software (8 bit)");
strcpy(name, "Software (8 bit)");
break;
case RENDERER_SOFTWARE_16BIT:
strcpy(name,"Software (16 bit)");
strcpy(name, "Software (16 bit)");
break;
case RENDERER_OPENGL:
strcpy(name,"OpenGL");
strcpy(name, "OpenGL");
break;
case RENDERER_DIRECT3D:
strcpy(name,"Direct3D");
strcpy(name, "Direct3D");
break;
case RENDERER_GLIDE:
strcpy(name,"3Dfx Glide");
strcpy(name, "3Dfx Glide");
break;
default:
temp.LoadString(IDS_3D_DETECT_NO3D);
strcpy(name,temp.GetBuffer(0));
strcpy(name, temp.GetBuffer(0));
break;
}
// tack on the Device name (if there is one)
if(strlen(card->name)>0) {
strcat(name," - ");
strcat(name,card->name);
if (strlen(card->name) > 0) {
strcat(name, " - ");
strcat(name, card->name);
}
return(name);
return (name);
}

View File

@@ -50,7 +50,6 @@
* $NoKeywords: $
*/
#ifndef _3D_DETECT_H
#define _3D_DETECT_H
@@ -59,8 +58,7 @@
#define MAX_CARDS 16
// The list of rendering device types
enum RendererType
{
enum RendererType {
RENDERER_SOFTWARE_8BIT,
RENDERER_SOFTWARE_16BIT,
RENDERER_OPENGL,

View File

@@ -164,7 +164,6 @@
#include "OS_Config.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
@@ -204,21 +203,14 @@ static SoundCard Cards[MAX_CARDS];
static int Num_cards;
// the callback for the DirectSound enumeration process
BOOL WINAPI dsound_enum_callback
(
GUID FAR * lpGuid,
LPSTR lpDeviceDescription,
LPSTR lpDeviceName,
LPVOID lpContext
)
{
SoundCard *card=&Cards[Num_cards++];
BOOL WINAPI dsound_enum_callback(GUID FAR *lpGuid, LPSTR lpDeviceDescription, LPSTR lpDeviceName, LPVOID lpContext) {
SoundCard *card = &Cards[Num_cards++];
if ( lpGuid ) {
memmove( &card->guid, lpGuid, sizeof(GUID) );
if (lpGuid) {
memmove(&card->guid, lpGuid, sizeof(GUID));
card->pguid = &card->guid;
} else {
memset( &card->guid, 0, sizeof(GUID) );
memset(&card->guid, 0, sizeof(GUID));
card->pguid = NULL;
}
@@ -228,37 +220,26 @@ BOOL WINAPI dsound_enum_callback
return TRUE;
}
// Creates a Primary direct sound buffer
HRESULT
CreateDSBuffer
(
LPDIRECTSOUND lpDirectSound,
int buffer_type,
LPDIRECTSOUNDBUFFER *lp_lp_dsb,
DWORD sound_bytes,
DWORD frequency,
bool f_is_stereo,
bool f_is_16_bit,
bool positional
)
{
CreateDSBuffer(LPDIRECTSOUND lpDirectSound, int buffer_type, LPDIRECTSOUNDBUFFER *lp_lp_dsb, DWORD sound_bytes,
DWORD frequency, bool f_is_stereo, bool f_is_16_bit, bool positional) {
DSBUFFERDESC dsbd;
tWAVEFORMATEX fmt;
HRESULT result;
if(frequency != 44100 && frequency != 22050 && frequency != 11025)
if (frequency != 44100 && frequency != 22050 && frequency != 11025)
return 0;
if(lpDirectSound==NULL)
if (lpDirectSound == NULL)
return 0;
// Setup the wave format
fmt.nChannels = (f_is_stereo)?2:1;
fmt.wBitsPerSample = (f_is_16_bit)?16:8;
fmt.nChannels = (f_is_stereo) ? 2 : 1;
fmt.wBitsPerSample = (f_is_16_bit) ? 16 : 8;
fmt.nSamplesPerSec = ((DWORD)frequency);
fmt.nBlockAlign = fmt.nChannels*(fmt.wBitsPerSample>>3);
fmt.nAvgBytesPerSec = ((DWORD)fmt.nSamplesPerSec)*((DWORD)fmt.nBlockAlign);
fmt.nBlockAlign = fmt.nChannels * (fmt.wBitsPerSample >> 3);
fmt.nAvgBytesPerSec = ((DWORD)fmt.nSamplesPerSec) * ((DWORD)fmt.nBlockAlign);
fmt.wFormatTag = WAVE_FORMAT_PCM;
// Setup the secondary direct sound buffer
@@ -270,11 +251,12 @@ CreateDSBuffer
// Setup for Software 16 bit mixer
dsbd.dwFlags = DSBCAPS_GETCURRENTPOSITION2;
if(buffer_type != SBT_PRIMARY) return 0;
if (buffer_type != SBT_PRIMARY)
return 0;
//m_primary_frequency = m_current_frequency = frequency;
//m_primary_bit_depth = fmt.wBitsPerSample;
//m_primary_alignment = fmt.nBlockAlign;
// m_primary_frequency = m_current_frequency = frequency;
// m_primary_bit_depth = fmt.wBitsPerSample;
// m_primary_alignment = fmt.nBlockAlign;
dsbd.lpwfxFormat = NULL;
dsbd.dwBufferBytes = 0;
@@ -286,8 +268,7 @@ CreateDSBuffer
// Create the buffer
result = lpDirectSound->CreateSoundBuffer(&dsbd, lp_lp_dsb, 0);
if (result == DS_OK && buffer_type == SBT_PRIMARY)
{
if (result == DS_OK && buffer_type == SBT_PRIMARY) {
// Succeeded. Set primary buffer to desired format.
result = (*lp_lp_dsb)->SetFormat(&fmt);
}
@@ -295,18 +276,16 @@ CreateDSBuffer
return result;
}
BOOL CreativeEAXCheck(LPDIRECTSOUND lpds)
{
BOOL retval=FALSE;
DWORD properties=0;
ULONG ulAnswer=0;
BOOL CreativeEAXCheck(LPDIRECTSOUND lpds) {
BOOL retval = FALSE;
DWORD properties = 0;
ULONG ulAnswer = 0;
LPKSPROPERTYSET lpksps = NULL;
WAVEFORMATEX wave;
DSBUFFERDESC dsbdesc;
LPDIRECTSOUNDBUFFER lpdsb=NULL;
LPDIRECTSOUNDBUFFER lpdsb = NULL;
const DWORD EAX_ENVIRONMENTS_AVAILABLE = 1,
EAX_BUFFERMIX_AVAILABLE =2;
const DWORD EAX_ENVIRONMENTS_AVAILABLE = 1, EAX_BUFFERMIX_AVAILABLE = 2;
memset(&wave, 0, sizeof(WAVEFORMATEX));
wave.wFormatTag = WAVE_FORMAT_PCM;
@@ -318,30 +297,27 @@ BOOL CreativeEAXCheck(LPDIRECTSOUND lpds)
memset(&dsbdesc, 0, sizeof(DSBUFFERDESC));
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
dsbdesc.dwFlags = DSBCAPS_STATIC|DSBCAPS_CTRL3D;
dsbdesc.dwBufferBytes = DSBSIZE_MIN*2;
dsbdesc.dwFlags = DSBCAPS_STATIC | DSBCAPS_CTRL3D;
dsbdesc.dwBufferBytes = DSBSIZE_MIN * 2;
dsbdesc.lpwfxFormat = &wave;
if ( FAILED(lpds->CreateSoundBuffer(&dsbdesc, &lpdsb, NULL)) ) {
if (FAILED(lpds->CreateSoundBuffer(&dsbdesc, &lpdsb, NULL))) {
retval = FALSE;
}
else if ( FAILED(lpdsb->QueryInterface(IID_IKsPropertySet, (LPVOID *)&lpksps)) ) {
} else if (FAILED(lpdsb->QueryInterface(IID_IKsPropertySet, (LPVOID *)&lpksps))) {
retval = FALSE;
}
else if (FAILED(lpksps->QuerySupport(DSPROPSETID_EAX_ReverbProperties, DSPROPERTY_EAX_ALL, &ulAnswer)) ) {
} else if (FAILED(lpksps->QuerySupport(DSPROPSETID_EAX_ReverbProperties, DSPROPERTY_EAX_ALL, &ulAnswer))) {
retval = FALSE;
}
else {
if ( (ulAnswer & KSPROPERTY_SUPPORT_SET|KSPROPERTY_SUPPORT_GET) == (KSPROPERTY_SUPPORT_SET|KSPROPERTY_SUPPORT_GET) ) {
} else {
if ((ulAnswer & KSPROPERTY_SUPPORT_SET | KSPROPERTY_SUPPORT_GET) ==
(KSPROPERTY_SUPPORT_SET | KSPROPERTY_SUPPORT_GET)) {
properties |= EAX_ENVIRONMENTS_AVAILABLE;
if (FAILED(lpksps->QuerySupport(DSPROPSETID_EAXBUFFER_ReverbProperties, DSPROPERTY_EAXBUFFER_REVERBMIX, &ulAnswer)) ) {
if (FAILED(lpksps->QuerySupport(DSPROPSETID_EAXBUFFER_ReverbProperties, DSPROPERTY_EAXBUFFER_REVERBMIX,
&ulAnswer))) {
retval = FALSE;
}
else {
} else {
properties |= EAX_BUFFERMIX_AVAILABLE;
}
}
else {
} else {
retval = FALSE;
}
}
@@ -353,47 +329,44 @@ BOOL CreativeEAXCheck(LPDIRECTSOUND lpds)
lpdsb->Release();
}
if (properties & (EAX_BUFFERMIX_AVAILABLE+EAX_ENVIRONMENTS_AVAILABLE)) {
if (properties & (EAX_BUFFERMIX_AVAILABLE + EAX_ENVIRONMENTS_AVAILABLE)) {
retval = TRUE;
}
return retval;
}
// Checks capabilities of given directsound device to see which mixers
// it can handle
bool DetermineMixerOptions(LPDIRECTSOUND lpDirectSound, UINT &mixer_flags)
{
bool DetermineMixerOptions(LPDIRECTSOUND lpDirectSound, UINT &mixer_flags) {
DSCAPS dscaps;
HRESULT hr;
// Default to just having DirectSound 8 bit available
mixer_flags=DS8BIT_MIXER;
mixer_flags = DS8BIT_MIXER;
dscaps.dwSize = sizeof(DSCAPS);
hr = lpDirectSound->GetCaps(&dscaps);
if(hr != DS_OK) {
if (hr != DS_OK) {
return FALSE;
}
/* We have decided to remove Direct Sound mixers as an option
/* We have decided to remove Direct Sound mixers as an option
// Check DirectSound 8 Bit support
if(dscaps.dwFlags & DSCAPS_PRIMARY8BIT)
mixer_flags |= DS8BIT_MIXER;
else
mixer_flags &= ~DS8BIT_MIXER;
*/
*/
// Check DirectSound 16 Bit support
if(dscaps.dwFlags & DSCAPS_PRIMARY16BIT)
if (dscaps.dwFlags & DSCAPS_PRIMARY16BIT)
mixer_flags |= DS16BIT_MIXER;
else
mixer_flags &= ~DS16BIT_MIXER;
#if (!defined(DEMO) && !defined(OEM_VOODOO3))
// Check DirectSound 3D Bit support
if(dscaps.dwMaxHw3DAllBuffers>0)
if (dscaps.dwMaxHw3DAllBuffers > 0)
mixer_flags |= DS3D_MIXER;
else
mixer_flags &= ~DS3D_MIXER;
@@ -401,13 +374,13 @@ bool DetermineMixerOptions(LPDIRECTSOUND lpDirectSound, UINT &mixer_flags)
// Check for Software and Creative EAX support
//////////////////////////////////////////////
if(dscaps.dwFlags & DSCAPS_EMULDRIVER)
if (dscaps.dwFlags & DSCAPS_EMULDRIVER)
return TRUE; // In NT or bad sound card, so don't set software flag
//Set the Cooperative level AND make sure it is ok to do it
// Set the Cooperative level AND make sure it is ok to do it
HRESULT scl_status;
scl_status = lpDirectSound->SetCooperativeLevel(pLaunchDlg->m_hWnd, DSSCL_WRITEPRIMARY);
if(scl_status != DS_OK)
if (scl_status != DS_OK)
return TRUE; // don't set software flag
// EAX support
@@ -418,16 +391,16 @@ bool DetermineMixerOptions(LPDIRECTSOUND lpDirectSound, UINT &mixer_flags)
// Try and create a buffer
HRESULT result;
LPDIRECTSOUNDBUFFER lp_primary_buffer;
lp_primary_buffer=NULL;
lp_primary_buffer = NULL;
// test software
result=CreateDSBuffer(lpDirectSound, SBT_PRIMARY, &lp_primary_buffer, 0, 22050, true, true, false);
result = CreateDSBuffer(lpDirectSound, SBT_PRIMARY, &lp_primary_buffer, 0, 22050, true, true, false);
// Make sure buffer was created successfully
if(lp_primary_buffer == NULL)
if (lp_primary_buffer == NULL)
return TRUE;
if(result!=DS_OK) {
if (result != DS_OK) {
lp_primary_buffer->Release();
return TRUE;
}
@@ -439,8 +412,7 @@ bool DetermineMixerOptions(LPDIRECTSOUND lpDirectSound, UINT &mixer_flags)
lp_primary_buffer->GetCaps(&dsbcaps);
// Is you want to see the caps, here is where -- mprintf all you want
if(!(dsbcaps.dwFlags & DSBCAPS_LOCHARDWARE))
{
if (!(dsbcaps.dwFlags & DSBCAPS_LOCHARDWARE)) {
lp_primary_buffer->Release();
return TRUE;
}
@@ -455,12 +427,11 @@ bool DetermineMixerOptions(LPDIRECTSOUND lpDirectSound, UINT &mixer_flags)
return TRUE;
}
typedef BOOL (CALLBACK *LPFN_DIRECTSOUNDENUMERATE)(LPDSENUMCALLBACKA lpDSEnumCallback, LPVOID lpContext);
typedef HRESULT (CALLBACK *LPFN_DIRECTSOUNDCREATE)(GUID FAR * lpGuid,LPDIRECTSOUND * ppDS,IUnknown FAR * pUnkOuter);
typedef BOOL(CALLBACK *LPFN_DIRECTSOUNDENUMERATE)(LPDSENUMCALLBACKA lpDSEnumCallback, LPVOID lpContext);
typedef HRESULT(CALLBACK *LPFN_DIRECTSOUNDCREATE)(GUID FAR *lpGuid, LPDIRECTSOUND *ppDS, IUnknown FAR *pUnkOuter);
// Adds any Direct Sound devices to the list of available sound settings
void check_direct_sound()
{
void check_direct_sound() {
int j;
HINSTANCE ds_dll_handle;
HRESULT dsrval;
@@ -469,55 +440,52 @@ void check_direct_sound()
LPDIRECTSOUND lpDirectSound;
ds_dll_handle = LoadLibrary("dsound.dll");
if (ds_dll_handle==NULL)
if (ds_dll_handle == NULL)
return;
// Get function pointers from DLL
pfn_DirectSoundEnumerate = (LPFN_DIRECTSOUNDENUMERATE) GetProcAddress(ds_dll_handle, "DirectSoundEnumerateA");
if (pfn_DirectSoundEnumerate==NULL) {
OutputDebugString( "Could not find DirectSoundEnumerate()\n" );
pfn_DirectSoundEnumerate = (LPFN_DIRECTSOUNDENUMERATE)GetProcAddress(ds_dll_handle, "DirectSoundEnumerateA");
if (pfn_DirectSoundEnumerate == NULL) {
OutputDebugString("Could not find DirectSoundEnumerate()\n");
goto DSoundCleanup;
}
pfn_DirectSoundCreate = (LPFN_DIRECTSOUNDCREATE) GetProcAddress(ds_dll_handle, "DirectSoundCreate");
if (pfn_DirectSoundCreate==NULL) {
OutputDebugString( "Could not find DirectSoundCreate()\n" );
pfn_DirectSoundCreate = (LPFN_DIRECTSOUNDCREATE)GetProcAddress(ds_dll_handle, "DirectSoundCreate");
if (pfn_DirectSoundCreate == NULL) {
OutputDebugString("Could not find DirectSoundCreate()\n");
goto DSoundCleanup;
}
// Enumerate sound cards/devices on user's system
dsrval = pfn_DirectSoundEnumerate((LPDSENUMCALLBACKA)dsound_enum_callback, NULL );
if ( dsrval != DS_OK ) {
OutputDebugString( "DirectSoundEnumerate failed.\n" );
dsrval = pfn_DirectSoundEnumerate((LPDSENUMCALLBACKA)dsound_enum_callback, NULL);
if (dsrval != DS_OK) {
OutputDebugString("DirectSoundEnumerate failed.\n");
goto DSoundCleanup;
}
// Evaluate mixer capabilities for each device
for(j=1; j<Num_cards; j++) {
for (j = 1; j < Num_cards; j++) {
// No matter what, allow default mixer to be selected
Cards[j].mixers=DS8BIT_MIXER;
Cards[j].mixers = DS8BIT_MIXER;
// Initialize Direct sound and get available mixers
if(DirectSoundCreate(Cards[j].pguid, &lpDirectSound, NULL) == DS_OK) {
if (DirectSoundCreate(Cards[j].pguid, &lpDirectSound, NULL) == DS_OK) {
// Creation succeeded.
//lpDirectSound->lpVtbl->SetCooperativeLevel(lpDirectSound, hwnd, DSSCL_NORMAL);
// lpDirectSound->lpVtbl->SetCooperativeLevel(lpDirectSound, hwnd, DSSCL_NORMAL);
// .
// . Place code to access DirectSound object here.
// .
DetermineMixerOptions(lpDirectSound,Cards[j].mixers);
DetermineMixerOptions(lpDirectSound, Cards[j].mixers);
lpDirectSound->Release();
}
else {
OutputDebugString( "DirectSoundCreate failed.\n" );
//goto DSoundCleanup;
} else {
OutputDebugString("DirectSoundCreate failed.\n");
// goto DSoundCleanup;
}
#if (!defined(DEMO) && !defined(OEM_VOODOO3))
// Try to initialize Aureal 3D sound
{
Cards[j].mixers &= ~AUREAL_MIXER;
}
{ Cards[j].mixers &= ~AUREAL_MIXER; }
#endif
}
@@ -531,20 +499,16 @@ DSoundCleanup:
IMPLEMENT_DYNCREATE(CAudioTab, CPropertyPage)
CAudioTab::CAudioTab() : CPropertyPage(CAudioTab::IDD)
{
CAudioTab::CAudioTab() : CPropertyPage(CAudioTab::IDD) {
//{{AFX_DATA_INIT(CAudioTab)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
CAudioTab::~CAudioTab()
{
}
CAudioTab::~CAudioTab() {}
// Fills in Cards and Num_cards
void detect_sound_cards(int really_detect)
{
void detect_sound_cards(int really_detect) {
Num_cards = 0;
CString no_sound_msg;
@@ -552,9 +516,9 @@ void detect_sound_cards(int really_detect)
// Setup "None" card slot
strcpy(Cards[Num_cards].name, no_sound_msg);
Cards[Num_cards].mixers=0;
Cards[Num_cards].pguid=NULL;
memset( &Cards[Num_cards].guid, 0, sizeof(GUID) );
Cards[Num_cards].mixers = 0;
Cards[Num_cards].pguid = NULL;
memset(&Cards[Num_cards].guid, 0, sizeof(GUID));
Num_cards++;
if (really_detect) {
@@ -562,8 +526,7 @@ void detect_sound_cards(int really_detect)
}
}
void CAudioTab::DoDataExchange(CDataExchange* pDX)
{
void CAudioTab::DoDataExchange(CDataExchange *pDX) {
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAudioTab)
DDX_Control(pDX, IDC_LAUNCHER_SND_CHECK, m_LauncherSndCheck);
@@ -571,21 +534,19 @@ void CAudioTab::DoDataExchange(CDataExchange* pDX)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAudioTab, CPropertyPage)
//{{AFX_MSG_MAP(CAudioTab)
ON_BN_CLICKED(IDC_BTN_AUDIO_DETECT, OnBtnAudioDetect)
ON_CBN_SELCHANGE(IDC_AUDIO_LIST, OnSelchangeAudioList)
ON_WM_HELPINFO()
ON_MESSAGE(WM_COMMANDHELP,OnCommandHelp)
//}}AFX_MSG_MAP
//{{AFX_MSG_MAP(CAudioTab)
ON_BN_CLICKED(IDC_BTN_AUDIO_DETECT, OnBtnAudioDetect)
ON_CBN_SELCHANGE(IDC_AUDIO_LIST, OnSelchangeAudioList)
ON_WM_HELPINFO()
ON_MESSAGE(WM_COMMANDHELP, OnCommandHelp)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAudioTab message handlers
void CAudioTab::OnBtnAudioDetect()
{
void CAudioTab::OnBtnAudioDetect() {
// TODO: Add your control notification handler code here
int i;
@@ -595,7 +556,7 @@ void CAudioTab::OnBtnAudioDetect()
// Display the scanning window
m_MsgDlg.m_ScanningMsg.LoadString(IDS_AUDIOTAB_SCANNING);
m_MsgDlg.m_WaitMsg.LoadString(IDS_PLEASE_WAIT_MSG);
m_MsgDlg.Create(IDD_MSG_DLG,this);
m_MsgDlg.Create(IDD_MSG_DLG, this);
m_MsgDlg.ShowWindow(SW_SHOW);
m_MsgDlg.UpdateData(FALSE);
@@ -605,19 +566,18 @@ void CAudioTab::OnBtnAudioDetect()
// Remove the scanning window
m_MsgDlg.DestroyWindow();
for (i=0; i<Num_cards; i++)
for (i = 0; i < Num_cards; i++)
m_audio_list.InsertString(i, Cards[i].name);
// Set selection and available mixer settings
m_audio_list.SetCurSel(Num_cards - 1);
EnableMixerSettings(Cards[Num_cards-1].mixers);
EnableMixerSettings(Cards[Num_cards - 1].mixers);
// Automatically default to software (if available)
SetMixerButton(DetermineDefaultMixer(Num_cards-1),Cards[Num_cards-1].mixers);
SetMixerButton(DetermineDefaultMixer(Num_cards - 1), Cards[Num_cards - 1].mixers);
}
void CAudioTab::OnOK()
{
void CAudioTab::OnOK() {
bool ds16_supported;
int current = m_audio_list.GetCurSel();
@@ -627,38 +587,37 @@ void CAudioTab::OnOK()
}
// See if the chosen card supports direct sound 16 bit
if(Cards[current].mixers & DS16BIT_MIXER)
ds16_supported=TRUE;
if (Cards[current].mixers & DS16BIT_MIXER)
ds16_supported = TRUE;
else
ds16_supported=FALSE;
ds16_supported = FALSE;
os_config_write_string(szSectionName, "SoundcardName", Cards[current].name);
int mixer_id;
mixer_id=GetMixerButton();
mixer_id = GetMixerButton();
// For Chris, make DS8 be the mixer if user has a card selected
// (other than No sound) and no sound mixers could be detected for
// the device
if(current>0 && mixer_id==SOUND_MIXER_NONE)
mixer_id=SOUND_MIXER_DS_8;
if (current > 0 && mixer_id == SOUND_MIXER_NONE)
mixer_id = SOUND_MIXER_DS_8;
// If user has ds16 support, and has chosen direct sound, use it
if(mixer_id==SOUND_MIXER_DS_8 && ds16_supported)
mixer_id=SOUND_MIXER_DS_16;
if (mixer_id == SOUND_MIXER_DS_8 && ds16_supported)
mixer_id = SOUND_MIXER_DS_16;
// Write out the default mixer
os_config_write_uint(NULL, "SoundMixer", mixer_id);
// Write out the Launcher sound setting
LauncherSoundEnabled=m_LauncherSndCheck.GetCheck();
LauncherSoundEnabled = m_LauncherSndCheck.GetCheck();
os_config_write_uint(szSectionName, "LauncherSoundEnabled", LauncherSoundEnabled);
CPropertyPage::OnOK();
}
BOOL CAudioTab::OnInitDialog()
{
BOOL CAudioTab::OnInitDialog() {
CPropertyPage::OnInitDialog();
// TODO: Add extra initialization here
@@ -676,13 +635,13 @@ BOOL CAudioTab::OnInitDialog()
// Display the scanning window
m_MsgDlg.m_ScanningMsg.LoadString(IDS_AUDIOTAB_SCANNING);
m_MsgDlg.m_WaitMsg.LoadString(IDS_PLEASE_WAIT_MSG);
m_MsgDlg.Create(IDD_MSG_DLG,this);
m_MsgDlg.Create(IDD_MSG_DLG, this);
m_MsgDlg.ShowWindow(SW_SHOW);
m_MsgDlg.UpdateData(FALSE);
// Detect all cards and fill the list
detect_sound_cards(1);
for (i=0; i<Num_cards; i++)
for (i = 0; i < Num_cards; i++)
m_audio_list.InsertString(i, Cards[i].name);
// Remove the scanning window
@@ -694,7 +653,7 @@ BOOL CAudioTab::OnInitDialog()
// Get the currently selected mixer
mixer_id = os_config_read_uint(NULL, "SoundMixer", SOUND_MIXER_NONE);
current=-1;
current = -1;
if (current_card) {
i = m_audio_list.FindStringExact(-1, current_card);
if (i != CB_ERR)
@@ -702,31 +661,30 @@ BOOL CAudioTab::OnInitDialog()
else {
// User's selected card could not be detected!
CString card_missing_msg, title_msg;
card_missing_msg.Format(IDS_AUDIOTAB_CARD_MISSING,current_card);
card_missing_msg.Format(IDS_AUDIOTAB_CARD_MISSING, current_card);
title_msg.LoadString(IDS_AUDIOTAB_WARNING);
MessageBox(card_missing_msg,title_msg, MB_OK | MB_ICONEXCLAMATION );
MessageBox(card_missing_msg, title_msg, MB_OK | MB_ICONEXCLAMATION);
}
}
else if (Num_cards>0) {
current=0;
} else if (Num_cards > 0) {
current = 0;
}
if (current < 0) {
current = Num_cards - 1;
mixer_id=DetermineDefaultMixer(current);
mixer_id = DetermineDefaultMixer(current);
}
// If it's the first time since install, autodetect the best card
if(theApp.m_straight_to_setup) {
current=DetermineBestCard();
mixer_id=DetermineDefaultMixer(current);
if (theApp.m_straight_to_setup) {
current = DetermineBestCard();
mixer_id = DetermineDefaultMixer(current);
}
// Set the current selection and available mixers
m_audio_list.SetCurSel(current);
EnableMixerSettings(Cards[current].mixers);
SetMixerButton(mixer_id,Cards[current].mixers);
SetMixerButton(mixer_id, Cards[current].mixers);
// Set the Launcher sound check button if necessary
LauncherSoundEnabled = os_config_read_uint(szSectionName, "LauncherSoundEnabled", 1);
@@ -736,92 +694,86 @@ BOOL CAudioTab::OnInitDialog()
// EXCEPTION: OCX Property Pages should return FALSE
}
void CAudioTab::OnSelchangeAudioList()
{
void CAudioTab::OnSelchangeAudioList() {
// TODO: Add your control notification handler code here
int index;
index=m_audio_list.GetCurSel();
if(index!=CB_ERR && index<Num_cards) {
index = m_audio_list.GetCurSel();
if (index != CB_ERR && index < Num_cards) {
EnableMixerSettings(Cards[index].mixers);
// Automatically default to software (if available)
SetMixerButton(DetermineDefaultMixer(index),Cards[index].mixers);
SetMixerButton(DetermineDefaultMixer(index), Cards[index].mixers);
}
}
// Determine the sound card with the most available mixers (for auto-detection)
int CAudioTab::DetermineBestCard(void)
{
int card_pos=0;
int CAudioTab::DetermineBestCard(void) {
int card_pos = 0;
int j;
for(j=0;j<Num_cards;j++)
if(Cards[j].mixers >= Cards[card_pos].mixers) card_pos=j;
for (j = 0; j < Num_cards; j++)
if (Cards[j].mixers >= Cards[card_pos].mixers)
card_pos = j;
return(card_pos);
return (card_pos);
}
// Enables/disables mixer options according to given mixer flags
void CAudioTab::EnableMixerSettings(UINT mixers)
{
void CAudioTab::EnableMixerSettings(UINT mixers) {
HWND hwnd;
GetDlgItem(IDC_MIXER_SOFTWARE,&hwnd);
GetDlgItem(IDC_MIXER_SOFTWARE, &hwnd);
::EnableWindow(hwnd, mixers & SOFTWARE_MIXER);
GetDlgItem(IDC_MIXER_DS8BIT,&hwnd);
GetDlgItem(IDC_MIXER_DS8BIT, &hwnd);
::EnableWindow(hwnd, mixers & DS8BIT_MIXER);
/* We're not handling directsound 8 or 16 visually anymore
/* We're not handling directsound 8 or 16 visually anymore
GetDlgItem(IDC_MIXER_DS16BIT,&hwnd);
::EnableWindow(hwnd, mixers & DS16BIT_MIXER);
*/
*/
GetDlgItem(IDC_MIXER_DS3D,&hwnd);
GetDlgItem(IDC_MIXER_DS3D, &hwnd);
::EnableWindow(hwnd, mixers & DS3D_MIXER);
GetDlgItem(IDC_MIXER_EAX,&hwnd);
GetDlgItem(IDC_MIXER_EAX, &hwnd);
::EnableWindow(hwnd, mixers & EAX_MIXER);
}
// selects the radio button corresponding to given registry ID
void CAudioTab::SetMixerButton(int mixer_id, UINT mixer_flags)
{
void CAudioTab::SetMixerButton(int mixer_id, UINT mixer_flags) {
// Turn them all off
((CButton *) GetDlgItem(IDC_MIXER_SOFTWARE))->SetCheck(0);
((CButton *) GetDlgItem(IDC_MIXER_DS16BIT))->SetCheck(0);
((CButton *) GetDlgItem(IDC_MIXER_DS8BIT))->SetCheck(0);
((CButton *) GetDlgItem(IDC_MIXER_DS3D))->SetCheck(0);
((CButton *) GetDlgItem(IDC_MIXER_EAX))->SetCheck(0);
((CButton *)GetDlgItem(IDC_MIXER_SOFTWARE))->SetCheck(0);
((CButton *)GetDlgItem(IDC_MIXER_DS16BIT))->SetCheck(0);
((CButton *)GetDlgItem(IDC_MIXER_DS8BIT))->SetCheck(0);
((CButton *)GetDlgItem(IDC_MIXER_DS3D))->SetCheck(0);
((CButton *)GetDlgItem(IDC_MIXER_EAX))->SetCheck(0);
// Now, check the appropriate one
switch(mixer_id) {
switch (mixer_id) {
case SOUND_MIXER_SOFTWARE_16:
if(mixer_flags & SOFTWARE_MIXER)
((CButton *) GetDlgItem(IDC_MIXER_SOFTWARE))->SetCheck(1);
if (mixer_flags & SOFTWARE_MIXER)
((CButton *)GetDlgItem(IDC_MIXER_SOFTWARE))->SetCheck(1);
break;
// Now set and DS mixer to Default
case SOUND_MIXER_DS_16:
if(mixer_flags & DS16BIT_MIXER)
((CButton *) GetDlgItem(IDC_MIXER_DS8BIT))->SetCheck(1);
if (mixer_flags & DS16BIT_MIXER)
((CButton *)GetDlgItem(IDC_MIXER_DS8BIT))->SetCheck(1);
break;
case SOUND_MIXER_DS_8:
if(mixer_flags & DS8BIT_MIXER)
((CButton *) GetDlgItem(IDC_MIXER_DS8BIT))->SetCheck(1);
if (mixer_flags & DS8BIT_MIXER)
((CButton *)GetDlgItem(IDC_MIXER_DS8BIT))->SetCheck(1);
break;
case SOUND_MIXER_DS3D_16:
if(mixer_flags & DS3D_MIXER)
((CButton *) GetDlgItem(IDC_MIXER_DS3D))->SetCheck(1);
if (mixer_flags & DS3D_MIXER)
((CButton *)GetDlgItem(IDC_MIXER_DS3D))->SetCheck(1);
break;
case SOUND_MIXER_EAX:
if(mixer_flags & EAX_MIXER)
((CButton *) GetDlgItem(IDC_MIXER_EAX))->SetCheck(1);
if (mixer_flags & EAX_MIXER)
((CButton *)GetDlgItem(IDC_MIXER_EAX))->SetCheck(1);
break;
default:
break;
@@ -829,48 +781,45 @@ void CAudioTab::SetMixerButton(int mixer_id, UINT mixer_flags)
}
// Returns the registry ID for the selected radio button
int CAudioTab::GetMixerButton(void)
{
int mixer_id=SOUND_MIXER_NONE;
int CAudioTab::GetMixerButton(void) {
int mixer_id = SOUND_MIXER_NONE;
if ( ((CButton *) GetDlgItem(IDC_MIXER_SOFTWARE))->GetCheck() == 1 )
mixer_id=SOUND_MIXER_SOFTWARE_16;
/*
if (((CButton *)GetDlgItem(IDC_MIXER_SOFTWARE))->GetCheck() == 1)
mixer_id = SOUND_MIXER_SOFTWARE_16;
/*
else if ( ((CButton *) GetDlgItem(IDC_MIXER_DS16BIT))->GetCheck() == 1 )
mixer_id=SOUND_MIXER_DS_16;
*/
else if ( ((CButton *) GetDlgItem(IDC_MIXER_DS8BIT))->GetCheck() == 1 )
mixer_id=SOUND_MIXER_DS_8;
else if ( ((CButton *) GetDlgItem(IDC_MIXER_DS3D))->GetCheck() == 1 )
mixer_id=SOUND_MIXER_DS3D_16;
else if ( ((CButton *) GetDlgItem(IDC_MIXER_EAX))->GetCheck() == 1 )
mixer_id=SOUND_MIXER_EAX;
*/
else if (((CButton *)GetDlgItem(IDC_MIXER_DS8BIT))->GetCheck() == 1)
mixer_id = SOUND_MIXER_DS_8;
else if (((CButton *)GetDlgItem(IDC_MIXER_DS3D))->GetCheck() == 1)
mixer_id = SOUND_MIXER_DS3D_16;
else if (((CButton *)GetDlgItem(IDC_MIXER_EAX))->GetCheck() == 1)
mixer_id = SOUND_MIXER_EAX;
return(mixer_id);
return (mixer_id);
}
// Returns the default mixer for a given card index
UINT CAudioTab::DetermineDefaultMixer(int card_index)
{
UINT CAudioTab::DetermineDefaultMixer(int card_index) {
int mixer_type;
// make 8 bit direct sound the generic default
mixer_type=SOUND_MIXER_DS_8;
mixer_type = SOUND_MIXER_DS_8;
// make sure index is valid
if(card_index<0 || card_index>=Num_cards)
return(mixer_type);
if (card_index < 0 || card_index >= Num_cards)
return (mixer_type);
// if mixer supports software, make it the default
if(Cards[card_index].mixers & SOFTWARE_MIXER)
mixer_type=SOUND_MIXER_SOFTWARE_16;
if (Cards[card_index].mixers & SOFTWARE_MIXER)
mixer_type = SOUND_MIXER_SOFTWARE_16;
return(mixer_type);
return (mixer_type);
}
// Display the html help file
BOOL CAudioTab::OnHelpInfo(HELPINFO* pHelpInfo)
{
BOOL CAudioTab::OnHelpInfo(HELPINFO *pHelpInfo) {
#ifdef USE_HTML_HELP_SYSTEM
CWaitCursor wc;
help_launch(AUDIOTAB_HELP);
@@ -881,13 +830,11 @@ BOOL CAudioTab::OnHelpInfo(HELPINFO* pHelpInfo)
}
// Display the html help file
afx_msg LRESULT CAudioTab::OnCommandHelp(WPARAM wParam, LPARAM lParam)
{
afx_msg LRESULT CAudioTab::OnCommandHelp(WPARAM wParam, LPARAM lParam) {
#ifdef USE_HTML_HELP_SYSTEM
help_launch(AUDIOTAB_HELP);
return 1;
#else
return CPropertyPage::OnCommandHelp(wParam,lParam);
return CPropertyPage::OnCommandHelp(wParam, lParam);
#endif
}

View File

@@ -67,11 +67,10 @@
/////////////////////////////////////////////////////////////////////////////
// CAudioTab dialog
class CAudioTab : public CPropertyPage
{
class CAudioTab : public CPropertyPage {
DECLARE_DYNCREATE(CAudioTab)
// Construction
// Construction
public:
CAudioTab();
~CAudioTab();
@@ -83,38 +82,36 @@ public:
CMsgDlg m_MsgDlg;
// Dialog Data
// Dialog Data
//{{AFX_DATA(CAudioTab)
enum { IDD = IDD_PROPPAGE_AUDIO };
CButton m_LauncherSndCheck;
CComboBox m_audio_list;
//}}AFX_DATA
// Overrides
// Overrides
// ClassWizard generate virtual function overrides
//{{AFX_VIRTUAL(CAudioTab)
public:
public:
virtual void OnOK();
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
protected:
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CAudioTab)
afx_msg void OnBtnAudioDetect();
virtual BOOL OnInitDialog();
afx_msg void OnSelchangeAudioList();
afx_msg BOOL OnHelpInfo(HELPINFO* pHelpInfo);
afx_msg BOOL OnHelpInfo(HELPINFO *pHelpInfo);
afx_msg LRESULT OnCommandHelp(WPARAM wParam, LPARAM lParam);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.

View File

@@ -126,106 +126,98 @@ static char THIS_FILE[] = __FILE__;
#define TOPBUTTON_TEXT_HEIGHT 17
// Define text colors for button states
#define UP_TEXT_COLOR PALETTERGB(162,167,204)
#define UP_TEXT_SHADOW_COLOR PALETTERGB(139,146,190)
#define DOWN_TEXT_COLOR PALETTERGB(255,255,255)
#define DOWN_TEXT_SHADOW_COLOR PALETTERGB(192,192,192)
#define LIT_TEXT_COLOR PALETTERGB(255,255,255)
#define LIT_TEXT_SHADOW_COLOR PALETTERGB(192,192,192)
#define DISABLED_TEXT_COLOR PALETTERGB(128,128,128)
#define DISABLED_TEXT_SHADOW_COLOR PALETTERGB(128,128,128)
#define UP_TEXT_COLOR PALETTERGB(162, 167, 204)
#define UP_TEXT_SHADOW_COLOR PALETTERGB(139, 146, 190)
#define DOWN_TEXT_COLOR PALETTERGB(255, 255, 255)
#define DOWN_TEXT_SHADOW_COLOR PALETTERGB(192, 192, 192)
#define LIT_TEXT_COLOR PALETTERGB(255, 255, 255)
#define LIT_TEXT_SHADOW_COLOR PALETTERGB(192, 192, 192)
#define DISABLED_TEXT_COLOR PALETTERGB(128, 128, 128)
#define DISABLED_TEXT_SHADOW_COLOR PALETTERGB(128, 128, 128)
/////////////////////////////////////////////////////////////////////////////
// CBitmapButtonEx
CBitmapButtonEx::CBitmapButtonEx()
{
m_MouseOverBtn=FALSE;
m_Hidden=FALSE;
CBitmapButtonEx::CBitmapButtonEx() {
m_MouseOverBtn = FALSE;
m_Hidden = FALSE;
m_TextMessage=""; // Default to no string message
m_Orientation=LEFT_ORIENTED_BTN; // Default to left orientation
m_TextMessage = ""; // Default to no string message
m_Orientation = LEFT_ORIENTED_BTN; // Default to left orientation
m_AnimBitmaps=NULL;
m_NumAnimFrames=0;
m_CurrAnimFrame=0;
m_IgnoreDisabled=FALSE;
m_AnimBitmaps = NULL;
m_NumAnimFrames = 0;
m_CurrAnimFrame = 0;
m_IgnoreDisabled = FALSE;
}
CBitmapButtonEx::~CBitmapButtonEx()
{
CBitmapButtonEx::~CBitmapButtonEx() {
// Delete the allocated bitmaps
if(m_AnimBitmaps!=NULL) delete[] m_AnimBitmaps;
if (m_AnimBitmaps != NULL)
delete[] m_AnimBitmaps;
// Detach this from the button object
Detach();
}
BEGIN_MESSAGE_MAP(CBitmapButtonEx, CBitmapButton)
//{{AFX_MSG_MAP(CBitmapButtonEx)
ON_WM_ERASEBKGND()
//}}AFX_MSG_MAP
//{{AFX_MSG_MAP(CBitmapButtonEx)
ON_WM_ERASEBKGND()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBitmapButtonEx message handlers
// Draw the button
void CBitmapButtonEx::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
void CBitmapButtonEx::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) {
// TODO: Add your code to draw the specified item
CBitmap *bitmap;
CPalette *palette;
COLORREF old_color, new_color, new_shadow_color;
CFont *old_font=NULL;
CBitmap *old_bitmap=NULL;
CPalette *old_palette=NULL;
int old_mode=0;
UINT old_alignment=0;
CFont *old_font = NULL;
CBitmap *old_bitmap = NULL;
CPalette *old_palette = NULL;
int old_mode = 0;
UINT old_alignment = 0;
// If button is hidden, don't draw it
if(m_Hidden) return;
if (m_Hidden)
return;
// Get button's state and draw appropriate bitmap
if(m_AnimBitmaps!=NULL) {
bitmap=&m_AnimBitmaps[m_CurrAnimFrame];
new_color=DOWN_TEXT_COLOR;
new_shadow_color=DOWN_TEXT_SHADOW_COLOR;
}
else if(lpDrawItemStruct->itemState & ODS_SELECTED) {
bitmap=&m_DownBitmap;
new_color=DOWN_TEXT_COLOR;
new_shadow_color=DOWN_TEXT_SHADOW_COLOR;
}
else if(!m_IgnoreDisabled && lpDrawItemStruct->itemState & ODS_DISABLED) {
bitmap=&m_DisabledBitmap;
new_color=DISABLED_TEXT_COLOR;
new_shadow_color=DISABLED_TEXT_SHADOW_COLOR;
}
else if(m_MouseOverBtn || lpDrawItemStruct->itemState & ODS_FOCUS) {
bitmap=&m_MouseBitmap;
new_color=LIT_TEXT_COLOR;
new_shadow_color=LIT_TEXT_SHADOW_COLOR;
}
else {
bitmap=&m_UpBitmap;
new_color=UP_TEXT_COLOR;
new_shadow_color=UP_TEXT_SHADOW_COLOR;
if (m_AnimBitmaps != NULL) {
bitmap = &m_AnimBitmaps[m_CurrAnimFrame];
new_color = DOWN_TEXT_COLOR;
new_shadow_color = DOWN_TEXT_SHADOW_COLOR;
} else if (lpDrawItemStruct->itemState & ODS_SELECTED) {
bitmap = &m_DownBitmap;
new_color = DOWN_TEXT_COLOR;
new_shadow_color = DOWN_TEXT_SHADOW_COLOR;
} else if (!m_IgnoreDisabled && lpDrawItemStruct->itemState & ODS_DISABLED) {
bitmap = &m_DisabledBitmap;
new_color = DISABLED_TEXT_COLOR;
new_shadow_color = DISABLED_TEXT_SHADOW_COLOR;
} else if (m_MouseOverBtn || lpDrawItemStruct->itemState & ODS_FOCUS) {
bitmap = &m_MouseBitmap;
new_color = LIT_TEXT_COLOR;
new_shadow_color = LIT_TEXT_SHADOW_COLOR;
} else {
bitmap = &m_UpBitmap;
new_color = UP_TEXT_COLOR;
new_shadow_color = UP_TEXT_SHADOW_COLOR;
}
// Use the Application default palette (speeds things up in 256 color)
palette=&theApp.m_palette;
palette = &theApp.m_palette;
//RECT rect=lpDrawItemStruct->rcItem;
// RECT rect=lpDrawItemStruct->rcItem;
// Obtain the client window for this button
CClientDC *dc;
try {
dc=new CClientDC(this);
}
catch(CResourceException) {
dc = new CClientDC(this);
} catch (CResourceException) {
OutputDebugString("Could not get ClientDC for bitmap button!\n");
}
@@ -238,77 +230,75 @@ void CBitmapButtonEx::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
bitmap->GetObject(sizeof(BITMAP), &m_bmInfo);
// Select and realize the palette
if( dc->GetDeviceCaps(RASTERCAPS) & RC_PALETTE && palette->m_hObject != NULL ) {
old_palette=dc->SelectPalette( palette, TRUE );
if (dc->GetDeviceCaps(RASTERCAPS) & RC_PALETTE && palette->m_hObject != NULL) {
old_palette = dc->SelectPalette(palette, TRUE);
dc->RealizePalette();
}
if(memDC.CreateCompatibleDC(dc)==0)
if (memDC.CreateCompatibleDC(dc) == 0)
OutputDebugString("CreateCompatibleDC() failed.\n");
if((old_bitmap=memDC.SelectObject( bitmap )) == NULL)
if ((old_bitmap = memDC.SelectObject(bitmap)) == NULL)
OutputDebugString("SelectObject() failed!\n");
dc->StretchBlt( 0, 0,crect.Width(),crect.Height(), &memDC, 0, 0, m_bmInfo.bmWidth,m_bmInfo.bmHeight,SRCCOPY );
dc->StretchBlt(0, 0, crect.Width(), crect.Height(), &memDC, 0, 0, m_bmInfo.bmWidth, m_bmInfo.bmHeight, SRCCOPY);
// If the button contains a text message, display it
if(!m_TextMessage.IsEmpty()) {
if (!m_TextMessage.IsEmpty()) {
//old_font = (CFont *)dc->SelectStockObject( ANSI_VAR_FONT );
old_font = dc->SelectObject( &m_btn_font );
old_mode=dc->SetBkMode(TRANSPARENT);
old_alignment=dc->SetTextAlign(TA_CENTER | TA_TOP);
old_color=dc->SetTextColor(new_shadow_color);
// old_font = (CFont *)dc->SelectStockObject( ANSI_VAR_FONT );
old_font = dc->SelectObject(&m_btn_font);
old_mode = dc->SetBkMode(TRANSPARENT);
old_alignment = dc->SetTextAlign(TA_CENTER | TA_TOP);
old_color = dc->SetTextColor(new_shadow_color);
dc->ExtTextOut( m_TextStartPoint.x-1,m_TextStartPoint.y,
ETO_CLIPPED,&m_TextClipBox,m_TextMessage,NULL);
dc->ExtTextOut(m_TextStartPoint.x - 1, m_TextStartPoint.y, ETO_CLIPPED, &m_TextClipBox, m_TextMessage, NULL);
dc->SetTextColor(new_color);
//dc->Rectangle(&m_TextClipBox);
dc->ExtTextOut( m_TextStartPoint.x,m_TextStartPoint.y,
ETO_CLIPPED,&m_TextClipBox,m_TextMessage,NULL);
//dc->DrawText(m_TextMessage,&m_TextClipBox,DT_CENTER);
// dc->Rectangle(&m_TextClipBox);
dc->ExtTextOut(m_TextStartPoint.x, m_TextStartPoint.y, ETO_CLIPPED, &m_TextClipBox, m_TextMessage, NULL);
// dc->DrawText(m_TextMessage,&m_TextClipBox,DT_CENTER);
dc->SetTextColor(old_color);
dc->SetTextAlign(old_alignment);
dc->SetBkMode(old_mode);
if(old_font!=NULL)
if (old_font != NULL)
dc->SelectObject(old_font);
}
if(old_bitmap!=NULL)
if (old_bitmap != NULL)
memDC.SelectObject(old_bitmap);
if(old_palette!=NULL)
dc->SelectPalette(old_palette,FALSE);
if (old_palette != NULL)
dc->SelectPalette(old_palette, FALSE);
if(memDC.DeleteDC()==0)
if (memDC.DeleteDC() == 0)
OutputDebugString("DeleteDC() failed!\n");
delete dc;
//CBitmapButton::DrawItem(lpDrawItemStruct);
// CBitmapButton::DrawItem(lpDrawItemStruct);
}
// Sets up the button for use
bool CBitmapButtonEx::Setup(UINT nID, CWnd *parent, int orient /*=LEFT_ORIENTED_BTN*/)
{
bool CBitmapButtonEx::Setup(UINT nID, CWnd *parent, int orient /*=LEFT_ORIENTED_BTN*/) {
CString res_name, title;
if(parent==NULL) return FALSE;
if (parent == NULL)
return FALSE;
// Let the bitmap class set things up for us
// NOTE:this function will also cause a redundant loading of bitmaps
// since CBitmapButton will store copies for itself, however,
// it is this funciton which automatically sets up the button's
// size, position, etc. from the resources...
//AutoLoad(nID,parent);
// AutoLoad(nID,parent);
// Attach this button instance to the proper button resource
HWND hwnd;
parent->GetDlgItem(nID,&hwnd);
if(Attach(hwnd)==0)
parent->GetDlgItem(nID, &hwnd);
if (Attach(hwnd) == 0)
OutputDebugString("Attach() failed!\n");
// Setup the text alignment values
@@ -316,118 +306,109 @@ bool CBitmapButtonEx::Setup(UINT nID, CWnd *parent, int orient /*=LEFT_ORIENTED_
// Fill in text parameters for different button orientations
int width, height;
if(m_Orientation==TOP_ORIENTED_BTN) {
if (m_Orientation == TOP_ORIENTED_BTN) {
// top oriented button
m_TextStartPoint.x=int(TOPBUTTON_TEXT_XOFFSET*DlgWidthModifier);
m_TextStartPoint.y=int(TOPBUTTON_TEXT_YOFFSET*DlgHeightModifier);
m_TextStartPoint.x = int(TOPBUTTON_TEXT_XOFFSET * DlgWidthModifier);
m_TextStartPoint.y = int(TOPBUTTON_TEXT_YOFFSET * DlgHeightModifier);
width=int(TOPBUTTON_TEXT_WIDTH*DlgWidthModifier);
height=int(TOPBUTTON_TEXT_HEIGHT*DlgHeightModifier);
width = int(TOPBUTTON_TEXT_WIDTH * DlgWidthModifier);
height = int(TOPBUTTON_TEXT_HEIGHT * DlgHeightModifier);
}
else if(m_Orientation==LEFT_ORIENTED_BTN) {
} else if (m_Orientation == LEFT_ORIENTED_BTN) {
// left oriented button
m_TextStartPoint.x=int(LEFTBUTTON_TEXT_XOFFSET*DlgWidthModifier);
m_TextStartPoint.y=int(BUTTON_TEXT_YOFFSET*DlgHeightModifier);
m_TextStartPoint.x = int(LEFTBUTTON_TEXT_XOFFSET * DlgWidthModifier);
m_TextStartPoint.y = int(BUTTON_TEXT_YOFFSET * DlgHeightModifier);
width=int(BUTTON_TEXT_WIDTH*DlgWidthModifier);
height=int(BUTTON_TEXT_HEIGHT*DlgHeightModifier);
width = int(BUTTON_TEXT_WIDTH * DlgWidthModifier);
height = int(BUTTON_TEXT_HEIGHT * DlgHeightModifier);
}
else {
} else {
// right oriented button
m_TextStartPoint.x=int(RIGHTBUTTON_TEXT_XOFFSET*DlgWidthModifier);
m_TextStartPoint.y=int(BUTTON_TEXT_YOFFSET*DlgHeightModifier);
m_TextStartPoint.x = int(RIGHTBUTTON_TEXT_XOFFSET * DlgWidthModifier);
m_TextStartPoint.y = int(BUTTON_TEXT_YOFFSET * DlgHeightModifier);
width=int(BUTTON_TEXT_WIDTH*DlgWidthModifier);
height=int(BUTTON_TEXT_HEIGHT*DlgHeightModifier);
width = int(BUTTON_TEXT_WIDTH * DlgWidthModifier);
height = int(BUTTON_TEXT_HEIGHT * DlgHeightModifier);
}
// Now compute the text bounding box from the button parameters
m_TextClipBox.left=m_TextStartPoint.x - (width/2);
m_TextClipBox.top=m_TextStartPoint.y;
m_TextClipBox.left = m_TextStartPoint.x - (width / 2);
m_TextClipBox.top = m_TextStartPoint.y;
m_TextClipBox.right=m_TextClipBox.left+width;
m_TextClipBox.bottom=m_TextClipBox.top+height;
m_TextClipBox.right = m_TextClipBox.left + width;
m_TextClipBox.bottom = m_TextClipBox.top + height;
// Set the font for the normal option buttons
m_btn_font.CreateFont(
int(14*DlgHeightModifier),
int(8*DlgWidthModifier),
0, 0, 0, 0, 0, 0, 0,
0, 0, PROOF_QUALITY,
0, _T("Arial Bold") );
m_btn_font.CreateFont(int(14 * DlgHeightModifier), int(8 * DlgWidthModifier), 0, 0, 0, 0, 0, 0, 0, 0, 0,
PROOF_QUALITY, 0, _T("Arial Bold"));
// Set the font for the logo buttons
m_logobtn_font.CreateFont(
int(14*DlgHeightModifier),
int(8*DlgWidthModifier),
0, 0, 0, 0, 0, 0, 0,
0, 0, PROOF_QUALITY,
0, _T("Arial Bold") );
m_logobtn_font.CreateFont(int(14 * DlgHeightModifier), int(8 * DlgWidthModifier), 0, 0, 0, 0, 0, 0, 0, 0, 0,
PROOF_QUALITY, 0, _T("Arial Bold"));
// Load the bitmaps and palettes that we will use
Load(nID,parent);
Load(nID, parent);
// Resize the buttons to match the proportions of the dialog
BITMAP bm;
m_UpBitmap.GetObject(sizeof(BITMAP), &bm);
SetWindowPos(NULL,0,0,int(bm.bmWidth*DlgWidthModifier),int(bm.bmHeight*DlgHeightModifier),SWP_NOMOVE|SWP_NOZORDER);
SetWindowPos(NULL, 0, 0, int(bm.bmWidth * DlgWidthModifier), int(bm.bmHeight * DlgHeightModifier),
SWP_NOMOVE | SWP_NOZORDER);
return TRUE;
}
// Sets up the animation button for use
bool CBitmapButtonEx::AnimSetup(UINT nID, CWnd *parent, int num_frames)
{
bool CBitmapButtonEx::AnimSetup(UINT nID, CWnd *parent, int num_frames) {
CString res_name, title;
if(num_frames==0) return FALSE;
if (num_frames == 0)
return FALSE;
if(parent==NULL) return FALSE;
if (parent == NULL)
return FALSE;
// Let the bitmap class set things up for us
// NOTE:this function will also cause a redundant loading of bitmaps
// since CBitmapButton will store copies for itself, however,
// it is this funciton which automatically sets up the button's
// size, position, etc. from the resources...
//AutoLoad(nID,parent);
// AutoLoad(nID,parent);
// Set the number of frames
m_NumAnimFrames=num_frames;
m_NumAnimFrames = num_frames;
// Attach this button instance to the proper button resource
HWND hwnd;
parent->GetDlgItem(nID,&hwnd);
if(Attach(hwnd)==0)
parent->GetDlgItem(nID, &hwnd);
if (Attach(hwnd) == 0)
OutputDebugString("Attach() failed!\n");
// Load the bitmaps and palettes that we will use
AnimLoad(nID,parent);
AnimLoad(nID, parent);
// Resize the buttons to match the proportions of the dialog
BITMAP bm;
m_AnimBitmaps[0].GetObject(sizeof(BITMAP), &bm);
SetWindowPos(NULL,0,0,int(bm.bmWidth*DlgWidthModifier),int(bm.bmHeight*DlgHeightModifier),SWP_NOMOVE|SWP_NOZORDER);
SetWindowPos(NULL, 0, 0, int(bm.bmWidth * DlgWidthModifier), int(bm.bmHeight * DlgHeightModifier),
SWP_NOMOVE | SWP_NOZORDER);
return TRUE;
}
// Loads the bitmaps for the button given
// U - up position
// D - down position
// M - lit (mouse is over it) position
// X - disabled
bool CBitmapButtonEx::Load(UINT nID, CWnd *parent)
{
bool CBitmapButtonEx::Load(UINT nID, CWnd *parent) {
CString res_name, title;
if(parent==NULL) return FALSE;
if (parent == NULL)
return FALSE;
parent->GetDlgItemText(nID, title);
@@ -435,26 +416,26 @@ bool CBitmapButtonEx::Load(UINT nID, CWnd *parent)
OutputDebugString(title);
OutputDebugString("\n");
res_name.Format("%s%s",title,"U");
GetBitmapAndPalette(res_name,&m_UpBitmap,NULL);
res_name.Format("%s%s",title,"D");
GetBitmapAndPalette(res_name,&m_DownBitmap,NULL);
res_name.Format("%s%s",title,"M");
GetBitmapAndPalette(res_name,&m_MouseBitmap,NULL);
res_name.Format("%s%s",title,"X");
GetBitmapAndPalette(res_name,&m_DisabledBitmap,NULL);
res_name.Format("%s%s", title, "U");
GetBitmapAndPalette(res_name, &m_UpBitmap, NULL);
res_name.Format("%s%s", title, "D");
GetBitmapAndPalette(res_name, &m_DownBitmap, NULL);
res_name.Format("%s%s", title, "M");
GetBitmapAndPalette(res_name, &m_MouseBitmap, NULL);
res_name.Format("%s%s", title, "X");
GetBitmapAndPalette(res_name, &m_DisabledBitmap, NULL);
return(TRUE);
return (TRUE);
}
// Loads the animation bitmaps for the button given
// Format: nameX where X is the frame #
bool CBitmapButtonEx::AnimLoad(UINT nID, CWnd *parent)
{
bool CBitmapButtonEx::AnimLoad(UINT nID, CWnd *parent) {
CString res_name, title;
int j;
if(parent==NULL) return FALSE;
if (parent == NULL)
return FALSE;
parent->GetDlgItemText(nID, title);
@@ -463,58 +444,47 @@ bool CBitmapButtonEx::AnimLoad(UINT nID, CWnd *parent)
OutputDebugString("\n");
// Allocate bitmap objects
if(m_NumAnimFrames==0) return FALSE;
m_AnimBitmaps=new CBitmap[m_NumAnimFrames];
if(m_AnimBitmaps==NULL) return FALSE;
if (m_NumAnimFrames == 0)
return FALSE;
m_AnimBitmaps = new CBitmap[m_NumAnimFrames];
if (m_AnimBitmaps == NULL)
return FALSE;
// Load in the bitmaps
for(j=0; j<m_NumAnimFrames; j++) {
res_name.Format("%s%d",title, j);
GetBitmapAndPalette(res_name,&m_AnimBitmaps[j],NULL);
for (j = 0; j < m_NumAnimFrames; j++) {
res_name.Format("%s%d", title, j);
GetBitmapAndPalette(res_name, &m_AnimBitmaps[j], NULL);
}
return(TRUE);
return (TRUE);
}
// Lights/un-Lights the button
void CBitmapButtonEx::Light(bool bLight)
{
m_MouseOverBtn = (bLight) ? TRUE : FALSE;
}
void CBitmapButtonEx::Light(bool bLight) { m_MouseOverBtn = (bLight) ? TRUE : FALSE; }
// Hides/un-Hides the button (and disables/enables it)
void CBitmapButtonEx::Hide(bool bHide)
{
void CBitmapButtonEx::Hide(bool bHide) {
m_Hidden = (bHide) ? TRUE : FALSE;
EnableWindow(!m_Hidden);
}
// Sets the button's text message
void CBitmapButtonEx::SetText(UINT nID)
{
m_TextMessage.LoadString(nID);
}
void CBitmapButtonEx::SetText(UINT nID) { m_TextMessage.LoadString(nID); }
// Increments the animation frame
void CBitmapButtonEx::DoNextAnimFrame(void)
{
void CBitmapButtonEx::DoNextAnimFrame(void) {
m_CurrAnimFrame++;
if(m_CurrAnimFrame==m_NumAnimFrames)
m_CurrAnimFrame=0;
if (m_CurrAnimFrame == m_NumAnimFrames)
m_CurrAnimFrame = 0;
}
// This function is called whenever the button's background needs to
// be erased. It simply returns saying that the button's background has already
// been erased - this is necessary to prevent the "gray-button-background"
// flicker during window updates
BOOL CBitmapButtonEx::OnEraseBkgnd(CDC* pDC)
{
BOOL CBitmapButtonEx::OnEraseBkgnd(CDC *pDC) {
// TODO: Add your message handler code here and/or call default
//return CBitmapButton::OnEraseBkgnd(pDC);
// return CBitmapButton::OnEraseBkgnd(pDC);
return 1;
}

View File

@@ -80,17 +80,15 @@
#define RIGHT_ORIENTED_BTN 1
#define TOP_ORIENTED_BTN 2
/////////////////////////////////////////////////////////////////////////////
// CBitmapButtonEx window
class CBitmapButtonEx : public CBitmapButton
{
// Construction
class CBitmapButtonEx : public CBitmapButton {
// Construction
public:
CBitmapButtonEx();
// Attributes
// Attributes
public:
// Button state bitmaps
CBitmap m_UpBitmap;
@@ -118,10 +116,10 @@ private:
bool m_IgnoreDisabled; // Allows buttons to be disabled functionality-wise,
// but not bitmap-wise
// Operations
// Operations
public:
// Sets up and loads the hi-color bitmaps and palettes
bool Setup(UINT nID, CWnd *parent, int orient=LEFT_ORIENTED_BTN);
bool Setup(UINT nID, CWnd *parent, int orient = LEFT_ORIENTED_BTN);
bool AnimSetup(UINT nID, CWnd *parent, int num_frames);
bool Load(UINT nID, CWnd *parent); // Loads the hi-color bitmaps and palettes
@@ -131,26 +129,26 @@ public:
void SetText(UINT nID); // Sets the button's text message
void DoNextAnimFrame(void); // Points button to next animation frame
bool IsLit(void) { return(m_MouseOverBtn); } // checks if button is lit
bool IsHidden(void) { return(m_Hidden); } // checks if button is hidden
bool IsLit(void) { return (m_MouseOverBtn); } // checks if button is lit
bool IsHidden(void) { return (m_Hidden); } // checks if button is hidden
void IgnoreDisabled(bool value) { m_IgnoreDisabled=value; } // sets the ignore disabled flag
void IgnoreDisabled(bool value) { m_IgnoreDisabled = value; } // sets the ignore disabled flag
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CBitmapButtonEx)
public:
public:
virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
//}}AFX_VIRTUAL
// Implementation
// Implementation
public:
virtual ~CBitmapButtonEx();
// Generated message map functions
protected:
//{{AFX_MSG(CBitmapButtonEx)
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg BOOL OnEraseBkgnd(CDC *pDC);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()

File diff suppressed because it is too large Load Diff

View File

@@ -158,7 +158,7 @@
#endif // _MSC_VER >= 1000
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#error include 'stdafx.h' before including this file for PCH
#endif
/******************************
@@ -168,26 +168,26 @@
#define LAUNCHER_DEMO_VERSION_ID 1.0
// Uncomment this if you want to use the HTML help system for the launcher
//#define USE_HTML_HELP_SYSTEM
// #define USE_HTML_HELP_SYSTEM
// Uncomment one of the following if you want to do a special build
//#define DEMO
//#define DEMO2
//#define OEM_GENERIC
//#define OEM_VOODOO3
//#define OEM_KATMAI
//#define FULL_US_RELEASE
// #define DEMO
// #define DEMO2
// #define OEM_GENERIC
// #define OEM_VOODOO3
// #define OEM_KATMAI
// #define FULL_US_RELEASE
#define FULL_ROW_RELEASE
//#define FULL_AUSSIE_RELEASE
// #define FULL_AUSSIE_RELEASE
// Uncomment this if you are doing an initial UK version build
//#define INITIAL_UK_RELEASE
// #define INITIAL_UK_RELEASE
// Uncomment this if you are doing a non-LaserLock version (full ROW variation)
//#define ROW_NLL_RELEASE
// #define ROW_NLL_RELEASE
// Uncomment this is you are doing an OEM_VOODOO3 build but want it to support all API's
//#define USE_ALL_VIDEO_OPTIONS
// #define USE_ALL_VIDEO_OPTIONS
// Uncomment this if you want multi-language support
#define USE_MULTI_LANGUAGES
@@ -196,10 +196,10 @@
#define ENABLE_ITALIAN
// Uncomment this if you want GLSetup to be a non-selectable option
//#define DISABLE_GLSETUP
// #define DISABLE_GLSETUP
// Macro for computing a "comparable" version ID
#define VER(major, minor, build) (100*100*major+100*minor+build)
#define VER(major, minor, build) (100 * 100 * major + 100 * minor + build)
// Comment char to be used in version files
#define VERSION_FILE_COMMENT_CHAR ';'
@@ -222,8 +222,7 @@
// See D3Launch.cpp for the implementation of this class
//
class CD3LaunchApp : public CWinApp
{
class CD3LaunchApp : public CWinApp {
public:
CD3LaunchApp();
@@ -246,15 +245,15 @@ public:
// parse for special (outrage) command-line arguments
void OutrageParseCommandLine();
// Overrides
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CD3LaunchApp)
public:
public:
virtual BOOL InitInstance();
virtual int ExitInstance();
//}}AFX_VIRTUAL
// Implementation
// Implementation
//{{AFX_MSG(CD3LaunchApp)
// NOTE - the ClassWizard will add and remove member functions here.

File diff suppressed because it is too large Load Diff

View File

@@ -147,18 +147,17 @@
#define NUM_BITMAP_BUTTONS 10
class CD3LaunchDlg : public CDialog
{
// Construction
class CD3LaunchDlg : public CDialog {
// Construction
public:
CD3LaunchDlg(CWnd* pParent = NULL); // standard constructor
CD3LaunchDlg(CWnd *pParent = NULL); // standard constructor
bool MouseOverButton(CButton *button); // checks if mouse is over button
void RedrawButton(CButton *button); // marks button region for redraw
void RefreshDialog(void); // sets up launcher for new language
bool SetLanguageDLL(int lang_type); // sets up the new language resource DLL
void PlaySound(LPSTR lpName, bool OnlyPlayIfActiveWnd, bool WaitUntilDone, bool WaitForStartup=TRUE); // Plays a sound
void PlaySound(LPSTR lpName, bool OnlyPlayIfActiveWnd, bool WaitUntilDone,
bool WaitForStartup = TRUE); // Plays a sound
void HideButton(CBitmapButtonEx *button, bool mHide); // Hides (or un-hides) a button
@@ -171,9 +170,9 @@ public:
void RunOpenGLSetup(void); // runs the GLSetup executable from CD#1
//CDC m_dcMem; // Compatible memory DC for dialog
//CBrush m_brush; // Handle of hollow brush
//CBrush m_bkBrush; // Handle of background brush
// CDC m_dcMem; // Compatible memory DC for dialog
// CBrush m_brush; // Handle of hollow brush
// CBrush m_bkBrush; // Handle of background brush
BITMAP m_bmInfo; // Bitmap info
CPoint m_pt; // Position of bitmap
CSize m_size; // Size of bitmap
@@ -190,7 +189,7 @@ public:
// Timer ID variable
UINT m_timerID;
// Dialog Data
// Dialog Data
//{{AFX_DATA(CD3LaunchDlg)
enum { IDD = IDD_D3LAUNCH_DIALOG };
// NOTE: the ClassWizard will add data members here
@@ -198,14 +197,15 @@ public:
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CD3LaunchDlg)
public:
public:
virtual BOOL DestroyWindow();
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
virtual BOOL PreCreateWindow(CREATESTRUCT &cs);
//}}AFX_VIRTUAL
// Implementation
// Implementation
protected:
HICON m_hIcon;
@@ -223,15 +223,15 @@ protected:
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnBtnUpdate();
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg BOOL OnEraseBkgnd(CDC *pDC);
afx_msg void OnBtnPxo();
afx_msg void OnBtnUninstall();
afx_msg void OnBtnLight();
afx_msg void OnBtnDirectx();
afx_msg BOOL OnQueryNewPalette();
afx_msg void OnPaletteChanged( CWnd* pFocusWnd );
afx_msg void OnPaletteChanged(CWnd *pFocusWnd);
afx_msg LONG OnStraightToSetup(UINT, LONG);
afx_msg BOOL OnHelpInfo(HELPINFO* pHelpInfo);
afx_msg BOOL OnHelpInfo(HELPINFO *pHelpInfo);
afx_msg LRESULT OnCommandHelp(WPARAM wParam, LPARAM lParam);
virtual void OnOK();
//}}AFX_MSG

View File

@@ -78,39 +78,33 @@ extern HINSTANCE Dd_dll_handle;
IMPLEMENT_DYNCREATE(CDirectXTab, CPropertyPage)
CDirectXTab::CDirectXTab() : CPropertyPage(CDirectXTab::IDD)
{
CDirectXTab::CDirectXTab() : CPropertyPage(CDirectXTab::IDD) {
//{{AFX_DATA_INIT(CDirectXTab)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
CDirectXTab::~CDirectXTab()
{
}
CDirectXTab::~CDirectXTab() {}
void CDirectXTab::DoDataExchange(CDataExchange* pDX)
{
void CDirectXTab::DoDataExchange(CDataExchange *pDX) {
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDirectXTab)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDirectXTab, CPropertyPage)
//{{AFX_MSG_MAP(CDirectXTab)
ON_BN_CLICKED(IDC_GET_DX, OnGetDx)
ON_MESSAGE(WM_COMMANDHELP,OnCommandHelp)
ON_WM_HELPINFO()
//}}AFX_MSG_MAP
//{{AFX_MSG_MAP(CDirectXTab)
ON_BN_CLICKED(IDC_GET_DX, OnGetDx)
ON_MESSAGE(WM_COMMANDHELP, OnCommandHelp)
ON_WM_HELPINFO()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDirectXTab message handlers
BOOL CDirectXTab::OnInitDialog()
{
BOOL CDirectXTab::OnInitDialog() {
CPropertyPage::OnInitDialog();
// TODO: Add extra initialization here
@@ -118,8 +112,7 @@ BOOL CDirectXTab::OnInitDialog()
HKEY hKey = NULL;
if (Dd_dll_handle) {
lResult = RegOpenKeyEx(
HKEY_LOCAL_MACHINE, // Where it is
lResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, // Where it is
"Software\\Microsoft\\DirectX", // name of key
NULL, // DWORD reserved
KEY_QUERY_VALUE, // Allows all changes
@@ -131,12 +124,11 @@ BOOL CDirectXTab::OnInitDialog()
DWORD dwType, dwLen;
dwLen = 32;
lResult = RegQueryValueEx(
hKey, // Handle to key
lResult = RegQueryValueEx(hKey, // Handle to key
"Version", // The values name
NULL, // DWORD reserved
&dwType, // What kind it is
(uint8_t *) version, // value to set
(uint8_t *)version, // value to set
&dwLen // How many bytes to set
);
@@ -152,12 +144,11 @@ BOOL CDirectXTab::OnInitDialog()
DWORD dwType, dwLen;
dwLen = 4;
lResult = RegQueryValueEx(
hKey, // Handle to key
lResult = RegQueryValueEx(hKey, // Handle to key
"InstalledVersion", // The values name
NULL, // DWORD reserved
&dwType, // What kind it is
(uint8_t *) &val, // value to set
(uint8_t *)&val, // value to set
&dwLen // How many bytes to set
);
@@ -167,7 +158,6 @@ BOOL CDirectXTab::OnInitDialog()
Dx_version = val;
str.Format("%d.x", Dx_version);
GetDlgItem(IDC_DX_VERSION)->SetWindowText(str);
}
}
@@ -179,8 +169,7 @@ BOOL CDirectXTab::OnInitDialog()
CString msg;
msg.LoadString(IDS_DIRECTXTAB_OK);
GetDlgItem(IDC_DX_STATUS)->SetWindowText(msg.GetBuffer(0));
}
else if (Dx_version >= 3) {
} else if (Dx_version >= 3) {
CString msg;
msg.LoadString(IDS_DIRECTXTAB_UPD_REC);
GetDlgItem(IDC_DX_STATUS)->SetWindowText(msg.GetBuffer(0));
@@ -190,23 +179,16 @@ BOOL CDirectXTab::OnInitDialog()
// EXCEPTION: OCX Property Pages should return FALSE
}
// Takes user to DirectX web page
void CDirectXTab::OnGetDx()
{
url_launch("http://www.microsoft.com/directx/download.asp");
}
void CDirectXTab::OnGetDx() { url_launch("http://www.microsoft.com/directx/download.asp"); }
void CDirectXTab::OnOK()
{
void CDirectXTab::OnOK() {
// TODO: Add your specialized code here and/or call the base class
CPropertyPage::OnOK();
}
BOOL CDirectXTab::OnHelpInfo(HELPINFO* pHelpInfo)
{
BOOL CDirectXTab::OnHelpInfo(HELPINFO *pHelpInfo) {
// TODO: Add your message handler code here and/or call default
#ifdef USE_HTML_HELP_SYSTEM
CWaitCursor wc;
@@ -218,12 +200,11 @@ BOOL CDirectXTab::OnHelpInfo(HELPINFO* pHelpInfo)
}
// Display the html help file
afx_msg LRESULT CDirectXTab::OnCommandHelp(WPARAM wParam, LPARAM lParam)
{
afx_msg LRESULT CDirectXTab::OnCommandHelp(WPARAM wParam, LPARAM lParam) {
#ifdef USE_HTML_HELP_SYSTEM
help_launch(DIRECTXTAB_HELP);
return 1;
#else
return CPropertyPage::OnCommandHelp(wParam,lParam);
return CPropertyPage::OnCommandHelp(wParam, lParam);
#endif
}

View File

@@ -50,43 +50,41 @@
/////////////////////////////////////////////////////////////////////////////
// CDirectXTab dialog
class CDirectXTab : public CPropertyPage
{
class CDirectXTab : public CPropertyPage {
DECLARE_DYNCREATE(CDirectXTab)
// Construction
// Construction
public:
CDirectXTab();
~CDirectXTab();
// Dialog Data
// Dialog Data
//{{AFX_DATA(CDirectXTab)
enum { IDD = IDD_PROPPAGE_DIRECTX };
// NOTE - ClassWizard will add data members here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_DATA
// Overrides
// Overrides
// ClassWizard generate virtual function overrides
//{{AFX_VIRTUAL(CDirectXTab)
public:
public:
virtual void OnOK();
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
protected:
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CDirectXTab)
virtual BOOL OnInitDialog();
afx_msg void OnGetDx();
afx_msg LRESULT OnCommandHelp(WPARAM wParam, LPARAM lParam);
afx_msg BOOL OnHelpInfo(HELPINFO* pHelpInfo);
afx_msg BOOL OnHelpInfo(HELPINFO *pHelpInfo);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// DriversDlg.cpp : implementation file
//
@@ -32,66 +32,57 @@ static char THIS_FILE[] = __FILE__;
/////////////////////////////////////////////////////////////////////////////
// CDriversDlg dialog
CDriversDlg::CDriversDlg(CWnd* pParent /*=NULL*/)
: CDialog(CDriversDlg::IDD, pParent)
{
CDriversDlg::CDriversDlg(CWnd *pParent /*=NULL*/) : CDialog(CDriversDlg::IDD, pParent) {
//{{AFX_DATA_INIT(CDriversDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_Selection=INSTALL_NONE;
m_Selection = INSTALL_NONE;
}
void CDriversDlg::DoDataExchange(CDataExchange* pDX)
{
void CDriversDlg::DoDataExchange(CDataExchange *pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDriversDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDriversDlg, CDialog)
//{{AFX_MSG_MAP(CDriversDlg)
ON_BN_CLICKED(IDC_DIRECTX_BUTTON, OnDirectxButton)
ON_BN_CLICKED(IDC_GLSETUP_BUTTON, OnGlsetupButton)
//}}AFX_MSG_MAP
//{{AFX_MSG_MAP(CDriversDlg)
ON_BN_CLICKED(IDC_DIRECTX_BUTTON, OnDirectxButton)
ON_BN_CLICKED(IDC_GLSETUP_BUTTON, OnGlsetupButton)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDriversDlg message handlers
BOOL CDriversDlg::OnInitDialog()
{
BOOL CDriversDlg::OnInitDialog() {
CDialog::OnInitDialog();
m_Selection=INSTALL_NONE;
m_Selection = INSTALL_NONE;
#if (defined(OEM_VOODOO3) || defined(DISABLE_GLSETUP))
CWnd *button;
button=GetDlgItem(IDC_GLSETUP_BUTTON);
if(button!=NULL) button->EnableWindow(FALSE);
button = GetDlgItem(IDC_GLSETUP_BUTTON);
if (button != NULL)
button->EnableWindow(FALSE);
#endif
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDriversDlg::OnDirectxButton()
{
m_Selection=INSTALL_DIRECTX;
void CDriversDlg::OnDirectxButton() {
m_Selection = INSTALL_DIRECTX;
CDialog::OnOK();
}
void CDriversDlg::OnGlsetupButton()
{
m_Selection=INSTALL_GLSETUP;
void CDriversDlg::OnGlsetupButton() {
m_Selection = INSTALL_GLSETUP;
CDialog::OnOK();
}
void CDriversDlg::OnOK()
{
m_Selection=INSTALL_NONE;
void CDriversDlg::OnOK() {
m_Selection = INSTALL_NONE;
CDialog::OnOK();
}

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#if !defined(AFX_DRIVERSDLG_H__0325ACC0_CC01_11D2_A4E0_00A0C96ED60D__INCLUDED_)
#define AFX_DRIVERSDLG_H__0325ACC0_CC01_11D2_A4E0_00A0C96ED60D__INCLUDED_
@@ -25,7 +25,6 @@
// DriversDlg.h : header file
//
// Installation selections
#define INSTALL_NONE 0
#define INSTALL_DIRECTX 1
@@ -34,31 +33,28 @@
/////////////////////////////////////////////////////////////////////////////
// CDriversDlg dialog
class CDriversDlg : public CDialog
{
// Construction
class CDriversDlg : public CDialog {
// Construction
public:
CDriversDlg(CWnd* pParent = NULL); // standard constructor
CDriversDlg(CWnd *pParent = NULL); // standard constructor
int m_Selection;
// Dialog Data
// Dialog Data
//{{AFX_DATA(CDriversDlg)
enum { IDD = IDD_DRIVERS_DIALOG };
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA
// Overrides
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CDriversDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
protected:
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CDriversDlg)
virtual BOOL OnInitDialog();

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// FindFastDlg.cpp : implementation file
//
@@ -32,50 +32,40 @@ static char THIS_FILE[] = __FILE__;
/////////////////////////////////////////////////////////////////////////////
// CFindFastDlg dialog
CFindFastDlg::CFindFastDlg(CWnd* pParent /*=NULL*/)
: CDialog(CFindFastDlg::IDD, pParent)
{
CFindFastDlg::CFindFastDlg(CWnd *pParent /*=NULL*/) : CDialog(CFindFastDlg::IDD, pParent) {
//{{AFX_DATA_INIT(CFindFastDlg)
m_AlwaysTerminateFF = FALSE;
//}}AFX_DATA_INIT
}
void CFindFastDlg::DoDataExchange(CDataExchange* pDX)
{
void CFindFastDlg::DoDataExchange(CDataExchange *pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CFindFastDlg)
DDX_Check(pDX, IDC_FINDFASTCHKBOX, m_AlwaysTerminateFF);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CFindFastDlg, CDialog)
//{{AFX_MSG_MAP(CFindFastDlg)
ON_BN_CLICKED(IDC_FINDFASTCHKBOX, OnFindfastchkbox)
//}}AFX_MSG_MAP
//{{AFX_MSG_MAP(CFindFastDlg)
ON_BN_CLICKED(IDC_FINDFASTCHKBOX, OnFindfastchkbox)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFindFastDlg message handlers
void CFindFastDlg::OnFindfastchkbox()
{
void CFindFastDlg::OnFindfastchkbox() {
CButton *chkbox = (CButton *)GetDlgItem(IDC_FINDFASTCHKBOX);
CButton *no_btn = (CButton *)GetDlgItem(IDCANCEL);
if (chkbox->GetCheck() == 1) {
no_btn->EnableWindow(FALSE);
}
else {
} else {
no_btn->EnableWindow(TRUE);
}
}
BOOL CFindFastDlg::OnInitDialog()
{
BOOL CFindFastDlg::OnInitDialog() {
CDialog::OnInitDialog();
CButton *no_btn = (CButton *)GetDlgItem(IDCANCEL);

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#if !defined(AFX_FINDFASTDLG_H__261D1580_0FD4_11D3_AF2D_00A0C94B8467__INCLUDED_)
#define AFX_FINDFASTDLG_H__261D1580_0FD4_11D3_AF2D_00A0C94B8467__INCLUDED_
@@ -28,29 +28,26 @@
/////////////////////////////////////////////////////////////////////////////
// CFindFastDlg dialog
class CFindFastDlg : public CDialog
{
// Construction
class CFindFastDlg : public CDialog {
// Construction
public:
CFindFastDlg(CWnd* pParent = NULL); // standard constructor
CFindFastDlg(CWnd *pParent = NULL); // standard constructor
// Dialog Data
// Dialog Data
//{{AFX_DATA(CFindFastDlg)
enum { IDD = IDD_FINDFASTDLG };
BOOL m_AlwaysTerminateFF;
//}}AFX_DATA
// Overrides
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CFindFastDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
protected:
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CFindFastDlg)
afx_msg void OnFindfastchkbox();

View File

@@ -51,18 +51,13 @@ static char THIS_FILE[] = __FILE__;
/////////////////////////////////////////////////////////////////////////////
// CGLSetupDlg dialog
CGLSetupDlg::CGLSetupDlg(CWnd* pParent /*=NULL*/)
: CDialog(CGLSetupDlg::IDD, pParent)
{
CGLSetupDlg::CGLSetupDlg(CWnd *pParent /*=NULL*/) : CDialog(CGLSetupDlg::IDD, pParent) {
//{{AFX_DATA_INIT(CGLSetupDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CGLSetupDlg::DoDataExchange(CDataExchange* pDX)
{
void CGLSetupDlg::DoDataExchange(CDataExchange *pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CGLSetupDlg)
DDX_Control(pDX, IDC_INSTALL_BUTTON, m_InstallButton);
@@ -72,32 +67,30 @@ void CGLSetupDlg::DoDataExchange(CDataExchange* pDX)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CGLSetupDlg, CDialog)
//{{AFX_MSG_MAP(CGLSetupDlg)
ON_BN_CLICKED(IDC_INSTALL_BUTTON, OnInstallButton)
ON_BN_CLICKED(IDC_VISIT_BUTTON, OnVisitButton)
//}}AFX_MSG_MAP
//{{AFX_MSG_MAP(CGLSetupDlg)
ON_BN_CLICKED(IDC_INSTALL_BUTTON, OnInstallButton)
ON_BN_CLICKED(IDC_VISIT_BUTTON, OnVisitButton)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CGLSetupDlg message handlers
BOOL CGLSetupDlg::OnInitDialog()
{
BOOL CGLSetupDlg::OnInitDialog() {
CDialog::OnInitDialog();
// Check the system date, if it is after July 1999, the beta has expired
bool beta_expired=FALSE;
bool beta_expired = FALSE;
SYSTEMTIME sys_time;
GetSystemTime(&sys_time);
if(sys_time.wYear>1999)
beta_expired=TRUE;
else if(sys_time.wYear==1999 && sys_time.wMonth>7)
beta_expired=TRUE;
if (sys_time.wYear > 1999)
beta_expired = TRUE;
else if (sys_time.wYear == 1999 && sys_time.wMonth > 7)
beta_expired = TRUE;
if(beta_expired) {
if (beta_expired) {
CString msg;
msg.LoadString(IDS_GLSETUP_EXPIRED_MSG);
m_Info1Text.SetWindowText(msg.GetBuffer(0));
@@ -110,17 +103,8 @@ BOOL CGLSetupDlg::OnInitDialog()
// EXCEPTION: OCX Property Pages should return FALSE
}
void CGLSetupDlg::OnInstallButton()
{
CDialog::OnOK();
}
void CGLSetupDlg::OnInstallButton() { CDialog::OnOK(); }
void CGLSetupDlg::OnVisitButton()
{
url_launch("http://www.glsetup.com/");
}
void CGLSetupDlg::OnVisitButton() { url_launch("http://www.glsetup.com/"); }
void CGLSetupDlg::OnCancel()
{
CDialog::OnCancel();
}
void CGLSetupDlg::OnCancel() { CDialog::OnCancel(); }

View File

@@ -45,13 +45,12 @@
/////////////////////////////////////////////////////////////////////////////
// CGLSetupDlg dialog
class CGLSetupDlg : public CDialog
{
// Construction
class CGLSetupDlg : public CDialog {
// Construction
public:
CGLSetupDlg(CWnd* pParent = NULL); // standard constructor
CGLSetupDlg(CWnd *pParent = NULL); // standard constructor
// Dialog Data
// Dialog Data
//{{AFX_DATA(CGLSetupDlg)
enum { IDD = IDD_GLSETUP_DIALOG };
CButton m_InstallButton;
@@ -60,17 +59,15 @@ public:
CStatic m_Info1Text;
//}}AFX_DATA
// Overrides
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CGLSetupDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
protected:
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CGLSetupDlg)
virtual BOOL OnInitDialog();

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*---------------------------------------------------------------------------
*
@@ -33,7 +33,7 @@ extern "C" {
extern HRESULT A3dInitialize(void);
extern void A3dUninitialize(void);
extern HRESULT A3dCreate(GUID *,void **,IUnknown FAR *,DWORD);
extern HRESULT A3dCreate(GUID *, void **, IUnknown FAR *, DWORD);
extern HRESULT A3dRegister(void);
#ifdef __cplusplus

View File

@@ -97,25 +97,21 @@ static char THIS_FILE[] = __FILE__;
// Declare the joystick data
JoystickData joystick_data[MAX_NUM_JOYSTICKS];
int Num_joysticks=0;
int Num_joysticks = 0;
/////////////////////////////////////////////////////////////////////////////
// CJoystickTab property page
IMPLEMENT_DYNCREATE(CJoystickTab, CPropertyPage)
CJoystickTab::CJoystickTab() : CPropertyPage(CJoystickTab::IDD)
{
CJoystickTab::CJoystickTab() : CPropertyPage(CJoystickTab::IDD) {
//{{AFX_DATA_INIT(CJoystickTab)
//}}AFX_DATA_INIT
}
CJoystickTab::~CJoystickTab()
{
}
CJoystickTab::~CJoystickTab() {}
void CJoystickTab::DoDataExchange(CDataExchange* pDX)
{
void CJoystickTab::DoDataExchange(CDataExchange *pDX) {
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CJoystickTab)
DDX_Control(pDX, IDC_CHFLIGHT_CHECK, m_CHFlightEnabled);
@@ -125,34 +121,31 @@ void CJoystickTab::DoDataExchange(CDataExchange* pDX)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CJoystickTab, CPropertyPage)
//{{AFX_MSG_MAP(CJoystickTab)
ON_BN_CLICKED(IDC_BTN_CALIBRATE, OnBtnCalibrate)
ON_BN_CLICKED(IDC_BTN_DETECT, OnBtnDetect)
ON_CBN_SELCHANGE(IDC_JOYSTICK_LIST, OnSelchangeJoystickList)
ON_MESSAGE(WM_COMMANDHELP,OnCommandHelp)
ON_WM_HELPINFO()
//}}AFX_MSG_MAP
//{{AFX_MSG_MAP(CJoystickTab)
ON_BN_CLICKED(IDC_BTN_CALIBRATE, OnBtnCalibrate)
ON_BN_CLICKED(IDC_BTN_DETECT, OnBtnDetect)
ON_CBN_SELCHANGE(IDC_JOYSTICK_LIST, OnSelchangeJoystickList)
ON_MESSAGE(WM_COMMANDHELP, OnCommandHelp)
ON_WM_HELPINFO()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CJoystickTab message handlers
int GetJoystickName(int joy_num,char *szRegKey,char *szReturnName);
int GetJoystickName(int joy_num, char *szRegKey, char *szReturnName);
int di_detect_joysticks(int cur_joy, CComboBox *box);
void CJoystickTab::OnBtnCalibrate()
{
void CJoystickTab::OnBtnCalibrate() {
// TODO: Add your control notification handler code here
STARTUPINFO si;
PROCESS_INFORMATION pi;
memset( &si, 0, sizeof(STARTUPINFO) );
memset(&si, 0, sizeof(STARTUPINFO));
si.cb = sizeof(si);
BOOL ret = CreateProcess( NULL, // pointer to name of executable module
BOOL ret = CreateProcess(NULL, // pointer to name of executable module
"rundll32.exe shell32.dll,Control_RunDLL joy.cpl", // pointer to command line string
NULL, // pointer to process security attributes
NULL, // pointer to thread security attributes
@@ -164,82 +157,73 @@ void CJoystickTab::OnBtnCalibrate()
&pi // pointer to PROCESS_INFORMATION
);
if ( !ret ) {
if (!ret) {
char *lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
GetLastError(),
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
(LPTSTR)&lpMsgBuf, 0, NULL);
// Display the string.
CString err_msg;
err_msg.LoadString(IDS_JOYSTICKTAB_ERR1);
MessageBox( lpMsgBuf, err_msg, MB_OK | MB_ICONEXCLAMATION);
MessageBox(lpMsgBuf, err_msg, MB_OK | MB_ICONEXCLAMATION);
// Free the buffer.
LocalFree( lpMsgBuf );
LocalFree(lpMsgBuf);
}
}
// Detect all the joysticks
void CJoystickTab::DetectSticks()
{
void CJoystickTab::DetectSticks() {
char str[1024];
int j, max, cur_joy;
JOYCAPS JoyCaps;
Num_joysticks=0;
//m_joystick_list.ResetContent();
Num_joysticks = 0;
// m_joystick_list.ResetContent();
// Add "none" option
CString none_msg;
none_msg.LoadString(IDS_JOYSTICKTAB_NONE);
strcpy(joystick_data[Num_joysticks].name,none_msg.GetBuffer(0));
joystick_data[Num_joysticks].FF_capable=FALSE;
joystick_data[Num_joysticks].ID=JOYSTICK_NONE_ID;
strcpy(joystick_data[Num_joysticks].name, none_msg.GetBuffer(0));
joystick_data[Num_joysticks].FF_capable = FALSE;
joystick_data[Num_joysticks].ID = JOYSTICK_NONE_ID;
Num_joysticks++;
//index = m_joystick_list.InsertString(-1, none_msg);
// index = m_joystick_list.InsertString(-1, none_msg);
//m_joystick_list.SetItemData(index, 99999); // link joystick id to list item
//m_joystick_list.SetCurSel(0);
// m_joystick_list.SetItemData(index, 99999); // link joystick id to list item
// m_joystick_list.SetCurSel(0);
//cur_joy = os_config_read_uint(szSectionName, "CurrentJoystick", 0);
cur_joy=0;
if (di_detect_joysticks(cur_joy, &m_joystick_list)==0) {
// cur_joy = os_config_read_uint(szSectionName, "CurrentJoystick", 0);
cur_joy = 0;
if (di_detect_joysticks(cur_joy, &m_joystick_list) == 0) {
max = joyGetNumDevs();
for (j=JOYSTICKID1; j<JOYSTICKID1+max; j++) {
for (j = JOYSTICKID1; j < JOYSTICKID1 + max; j++) {
if (JOYERR_NOERROR == joyGetDevCaps(j, &JoyCaps, sizeof(JoyCaps))) {
char szReturnName[1024];
if ( !GetJoystickName(j,JoyCaps.szRegKey,szReturnName) ) {
strcpy( str, szReturnName );
if (!GetJoystickName(j, JoyCaps.szRegKey, szReturnName)) {
strcpy(str, szReturnName);
} else {
sprintf(str, "Joystick %d", j + 1);
}
strcpy(joystick_data[Num_joysticks].name,str);
joystick_data[Num_joysticks].FF_capable=FALSE;
joystick_data[Num_joysticks].ID=j;
strcpy(joystick_data[Num_joysticks].name, str);
joystick_data[Num_joysticks].FF_capable = FALSE;
joystick_data[Num_joysticks].ID = j;
Num_joysticks++;
//index = m_joystick_list.InsertString(-1, str);
//m_joystick_list.SetItemData(index, j); // link joystick id to list item
//if (j == cur_joy)
// index = m_joystick_list.InsertString(-1, str);
// m_joystick_list.SetItemData(index, j); // link joystick id to list item
// if (j == cur_joy)
// m_joystick_list.SetCurSel(index);
}
}
}
/*
/*
int ff_enabled = os_config_read_uint(szSectionName, "EnableJoystickFF", 0);
if (ff_enabled) {
m_ff_enabled.SetCheck(1);
@@ -247,18 +231,16 @@ void CJoystickTab::DetectSticks()
} else {
m_ff_enabled.SetCheck(0);
}
*/
*/
}
// Detect the sticks and fill the list box
BOOL CJoystickTab::OnInitDialog()
{
BOOL CJoystickTab::OnInitDialog() {
CPropertyPage::OnInitDialog();
// TODO: Add extra initialization here
// TODO: Add your control notification handler code here
//int cur_stick, i;
// int cur_stick, i;
int selected_stick;
HWND hwnd;
@@ -268,7 +250,7 @@ BOOL CJoystickTab::OnInitDialog()
// Display the scanning window
m_MsgDlg.m_ScanningMsg.LoadString(IDS_JOYSTICKTAB_SCANNING);
m_MsgDlg.m_WaitMsg.LoadString(IDS_PLEASE_WAIT_MSG);
m_MsgDlg.Create(IDD_MSG_DLG,this);
m_MsgDlg.Create(IDD_MSG_DLG, this);
m_MsgDlg.ShowWindow(SW_SHOW);
m_MsgDlg.UpdateData(FALSE);
@@ -279,11 +261,11 @@ BOOL CJoystickTab::OnInitDialog()
m_MsgDlg.DestroyWindow();
// Take the first joystick (if one exists)
if(Num_joysticks>1)
selected_stick=1; // First joystick in list
if (Num_joysticks > 1)
selected_stick = 1; // First joystick in list
else
selected_stick=0; // None
/*
selected_stick = 0; // None
/*
// Clear the list
m_joystick_list.ResetContent();
@@ -299,7 +281,7 @@ BOOL CJoystickTab::OnInitDialog()
// Set the joystick selection
m_joystick_list.SetCurSel(selected_stick);
*/
*/
// Display the primary joystick name in the text box
GetDlgItem(IDC_PRIMARY_JOYSTICK_TEXT)->SetWindowText(joystick_data[selected_stick].name);
@@ -315,7 +297,7 @@ BOOL CJoystickTab::OnInitDialog()
UpdateData(FALSE);
// Enable or disable the FF checkbox
GetDlgItem(IDC_FF_ENABLED,&hwnd);
GetDlgItem(IDC_FF_ENABLED, &hwnd);
#ifdef DEMO
::EnableWindow(hwnd, FALSE);
#else
@@ -323,7 +305,7 @@ BOOL CJoystickTab::OnInitDialog()
#endif
// Set the CHFlight checkbox is user wants to use that mode
if(os_config_read_uint(szSectionName, "EnableCHFlight", 0)) {
if (os_config_read_uint(szSectionName, "EnableCHFlight", 0)) {
m_CHFlightEnabled.SetCheck(1);
} else {
m_CHFlightEnabled.SetCheck(0);
@@ -331,7 +313,7 @@ BOOL CJoystickTab::OnInitDialog()
UpdateData(FALSE);
// Set the Mouseman checkbox is user wants to use that mode
if(os_config_read_uint(szSectionName, "EnableMouseman", 0)) {
if (os_config_read_uint(szSectionName, "EnableMouseman", 0)) {
m_MousemanEnabled.SetCheck(1);
} else {
m_MousemanEnabled.SetCheck(0);
@@ -342,11 +324,10 @@ BOOL CJoystickTab::OnInitDialog()
// EXCEPTION: OCX Property Pages should return FALSE
}
// JAS: Taken from Nov 1996 Game Developer, page 49.
// Damn, that is some UGLY code! (But it works...)
/*---------------------------------------------------------------------*/
int GetJoystickName(int joy_num,char *szRegKey,char *szReturnName)
int GetJoystickName(int joy_num, char *szRegKey, char *szReturnName)
/*
Description : Opens the MediaResources\Joysitick\mjstick.drv<xxxx>\JoystickSettings and
extracts Joystick%dOEMName string
@@ -365,75 +346,68 @@ int GetJoystickName(int joy_num,char *szRegKey,char *szReturnName)
HKEY OEMPropKey;
HKEY PropKey;
DWORD Length;
if( ERROR_SUCCESS != RegOpenKey( HKEY_LOCAL_MACHINE,REGSTR_PATH_JOYCONFIG,&ConfigKey ) )
if (ERROR_SUCCESS != RegOpenKey(HKEY_LOCAL_MACHINE, REGSTR_PATH_JOYCONFIG, &ConfigKey))
{
return( 1 ); // It should never get here key received from Caps
return (1); // It should never get here key received from Caps
}
if( ERROR_SUCCESS != RegOpenKey( ConfigKey, szRegKey, &DriverKey ) )
{
return( 1 ); // It should never get here key received from Caps
if (ERROR_SUCCESS != RegOpenKey(ConfigKey, szRegKey, &DriverKey)) {
return (1); // It should never get here key received from Caps
}
// Open CurrentSettings Key
if( ERROR_SUCCESS != RegOpenKey( DriverKey, REGSTR_KEY_JOYCURR, &JoyConfigKey ) )
{
return( 1 ); // It should never get here always a Current Settings
if (ERROR_SUCCESS != RegOpenKey(DriverKey, REGSTR_KEY_JOYCURR, &JoyConfigKey)) {
return (1); // It should never get here always a Current Settings
}
sprintf((char *)KeyStr,(char *)REGSTR_VAL_JOYNOEMNAME,joy_num+1);
Length=sizeof(szOEMName); // Get OEMNAME Configuration
sprintf((char *)KeyStr, (char *)REGSTR_VAL_JOYNOEMNAME, joy_num + 1);
Length = sizeof(szOEMName); // Get OEMNAME Configuration
if( ERROR_SUCCESS != RegQueryValueEx( JoyConfigKey,(char *)KeyStr,NULL,NULL,(uint8_t *)&szOEMName,&Length))
{
return( 1 ); // No OEM name listed return error
if (ERROR_SUCCESS != RegQueryValueEx(JoyConfigKey, (char *)KeyStr, NULL, NULL, (uint8_t *)&szOEMName, &Length)) {
return (1); // No OEM name listed return error
}
RegCloseKey( ConfigKey ); // Closes the registry Key
RegCloseKey(ConfigKey); // Closes the registry Key
// Open OEM Properties Key
if( ERROR_SUCCESS != RegOpenKey(HKEY_LOCAL_MACHINE,REGSTR_PATH_JOYOEM,&PropKey ) )
{
return( 1 ); // It should never get here key received from Caps
if (ERROR_SUCCESS != RegOpenKey(HKEY_LOCAL_MACHINE, REGSTR_PATH_JOYOEM, &PropKey)) {
return (1); // It should never get here key received from Caps
}
if( ERROR_SUCCESS != RegOpenKey( PropKey, (char *)szOEMName, &OEMPropKey ) )
{
return( 1 ); // It should never get here if device is selected
if (ERROR_SUCCESS != RegOpenKey(PropKey, (char *)szOEMName, &OEMPropKey)) {
return (1); // It should never get here if device is selected
}
Length=_MAX_PATH; // Get Name as listed in Control Panel
Length = _MAX_PATH; // Get Name as listed in Control Panel
if( ERROR_SUCCESS != RegQueryValueEx( OEMPropKey,REGSTR_VAL_JOYOEMNAME,NULL,NULL,(uint8_t *)szReturnName,&Length))
{
return( 1 ); // No OEM name listed return error
if (ERROR_SUCCESS !=
RegQueryValueEx(OEMPropKey, REGSTR_VAL_JOYOEMNAME, NULL, NULL, (uint8_t *)szReturnName, &Length)) {
return (1); // No OEM name listed return error
}
RegCloseKey( OEMPropKey ); // Closes the registry Key
RegCloseKey(OEMPropKey); // Closes the registry Key
return 0;
} /* End GetJoystickName */
void CJoystickTab::OnOK()
{
void CJoystickTab::OnOK() {
// TODO: Add your specialized code here and/or call the base class
//int index;
// int index;
int cur_joy = 0;
if ( m_ff_enabled.GetCheck() ) {
os_config_write_uint( szSectionName, "EnableJoystickFF", 1 );
if (m_ff_enabled.GetCheck()) {
os_config_write_uint(szSectionName, "EnableJoystickFF", 1);
} else {
os_config_write_uint( szSectionName, "EnableJoystickFF", 0 );
os_config_write_uint(szSectionName, "EnableJoystickFF", 0);
}
if ( m_CHFlightEnabled.GetCheck() ) {
os_config_write_uint( szSectionName, "EnableCHFlight", 1 );
if (m_CHFlightEnabled.GetCheck()) {
os_config_write_uint(szSectionName, "EnableCHFlight", 1);
} else {
os_config_write_uint( szSectionName, "EnableCHFlight", 0 );
os_config_write_uint(szSectionName, "EnableCHFlight", 0);
}
if ( m_MousemanEnabled.GetCheck() ) {
os_config_write_uint( szSectionName, "EnableMouseman", 1 );
if (m_MousemanEnabled.GetCheck()) {
os_config_write_uint(szSectionName, "EnableMouseman", 1);
} else {
os_config_write_uint( szSectionName, "EnableMouseman", 0 );
os_config_write_uint(szSectionName, "EnableMouseman", 0);
}
/*
@@ -449,23 +423,21 @@ void CJoystickTab::OnOK()
CPropertyPage::OnOK();
}
// Pointers to functions contained in DSOUND.dll
int Di_dll_loaded = 0;
HINSTANCE Di_dll_handle = NULL;
HRESULT (__stdcall *pfn_DirectInputCreate) (HINSTANCE, DWORD, LPDIRECTINPUT *, LPUNKNOWN) = NULL;
HRESULT(__stdcall *pfn_DirectInputCreate)(HINSTANCE, DWORD, LPDIRECTINPUT *, LPUNKNOWN) = NULL;
// obtain the function pointers from the dsound.dll
void di_dll_get_functions()
{
pfn_DirectInputCreate = (HRESULT (__stdcall *) (HINSTANCE, DWORD, LPDIRECTINPUT *, LPUNKNOWN)) GetProcAddress(Di_dll_handle, "DirectInputCreateA");
void di_dll_get_functions() {
pfn_DirectInputCreate = (HRESULT(__stdcall *)(HINSTANCE, DWORD, LPDIRECTINPUT *, LPUNKNOWN))GetProcAddress(
Di_dll_handle, "DirectInputCreateA");
}
// Load the dsound.dll, and get funtion pointers
// exit: 0 -> dll loaded successfully
// !0 -> dll could not be loaded
int di_dll_load()
{
int di_dll_load() {
if (!Di_dll_loaded) {
Di_dll_handle = LoadLibrary("dinput.dll");
if (!Di_dll_handle)
@@ -478,8 +450,7 @@ int di_dll_load()
return 0;
}
void di_dll_free()
{
void di_dll_free() {
if (Di_dll_loaded) {
FreeLibrary(Di_dll_handle);
Di_dll_handle = NULL;
@@ -497,13 +468,12 @@ struct stuff {
char msg_buffer[1024];
// Callback function for enumerating ALL joysticks
BOOL CALLBACK enum_joysticks(LPCDIDEVICEINSTANCE lpddi, LPVOID ptr)
{
BOOL CALLBACK enum_joysticks(LPCDIDEVICEINSTANCE lpddi, LPVOID ptr) {
int num;
stuff *stuffp = (stuff *) ptr;
stuff *stuffp = (stuff *)ptr;
OutputDebugString("Found joystick in enum!\n");
sprintf(msg_buffer,"%s (%s)\n", lpddi->tszProductName, lpddi->tszInstanceName);
sprintf(msg_buffer, "%s (%s)\n", lpddi->tszProductName, lpddi->tszInstanceName);
OutputDebugString(msg_buffer);
// Make sure it is a joystick
@@ -512,19 +482,19 @@ BOOL CALLBACK enum_joysticks(LPCDIDEVICEINSTANCE lpddi, LPVOID ptr)
// Get the joystick number
num = atoi(lpddi->tszInstanceName + 9) - 1;
sprintf(msg_buffer,"num=%d\n",num);
sprintf(msg_buffer, "num=%d\n", num);
OutputDebugString(msg_buffer);
// Fill in the data
sprintf(joystick_data[Num_joysticks].name, "%s (%s)", lpddi->tszProductName, lpddi->tszInstanceName);
joystick_data[Num_joysticks].FF_capable=FALSE;
joystick_data[Num_joysticks].ID=num;
/*
joystick_data[Num_joysticks].FF_capable = FALSE;
joystick_data[Num_joysticks].ID = num;
/*
i = stuffp->box->InsertString(-1, joystick_data[Num_joysticks].name);
stuffp->box->SetItemData(i, num);
if (num == stuffp->cur_joy)
stuffp->box->SetCurSel(i);
*/
*/
Num_joysticks++;
stuffp->count++;
@@ -533,8 +503,7 @@ BOOL CALLBACK enum_joysticks(LPCDIDEVICEINSTANCE lpddi, LPVOID ptr)
}
// Callback function for enumerating ONLY force feedback joysticks
BOOL CALLBACK enum_ff_joysticks(LPCDIDEVICEINSTANCE lpddi, LPVOID ptr)
{
BOOL CALLBACK enum_ff_joysticks(LPCDIDEVICEINSTANCE lpddi, LPVOID ptr) {
int i, num;
OutputDebugString("Found force feedback joystick in enum!\n");
@@ -549,11 +518,11 @@ BOOL CALLBACK enum_ff_joysticks(LPCDIDEVICEINSTANCE lpddi, LPVOID ptr)
num = atoi(lpddi->tszInstanceName + 9) - 1;
// Set the ff_capable flag of this joystick
for(i=0;i<Num_joysticks;i++)
if(joystick_data[i].ID==num)
joystick_data[i].FF_capable=TRUE;
for (i = 0; i < Num_joysticks; i++)
if (joystick_data[i].ID == num)
joystick_data[i].FF_capable = TRUE;
/*
/*
strcpy(buf, lpddi->tszInstanceName);
if (strnicmp(buf, "Joystick ", 9))
return DIENUM_CONTINUE;
@@ -576,12 +545,11 @@ BOOL CALLBACK enum_ff_joysticks(LPCDIDEVICEINSTANCE lpddi, LPVOID ptr)
stuffp->box->SetCurSel(i);
stuffp->count++;
*/
*/
return DIENUM_CONTINUE;
}
int di_detect_joysticks(int cur_joy, CComboBox *box)
{
int di_detect_joysticks(int cur_joy, CComboBox *box) {
HRESULT hr;
LPDIRECTINPUT di_joystick_obj;
stuff s;
@@ -607,9 +575,9 @@ int di_detect_joysticks(int cur_joy, CComboBox *box)
s.box = box;
s.cur_joy = cur_joy;
//hr = di_joystick_obj->EnumDevices(DIDEVTYPE_JOYSTICK, enum_joysticks, &s, DIEDFL_ALLDEVICES);
// hr = di_joystick_obj->EnumDevices(DIDEVTYPE_JOYSTICK, enum_joysticks, &s, DIEDFL_ALLDEVICES);
hr = di_joystick_obj->EnumDevices(DIDEVTYPE_JOYSTICK, enum_joysticks, &s, DIEDFL_ATTACHEDONLY);
if(hr==DIERR_INVALIDPARAM) {
if (hr == DIERR_INVALIDPARAM) {
OutputDebugString("Bad parm\n");
}
if (FAILED(hr)) {
@@ -619,9 +587,10 @@ int di_detect_joysticks(int cur_joy, CComboBox *box)
}
// Enumerate any force feedback devices if at least one joystick was found
if(s.count>0) {
hr = di_joystick_obj->EnumDevices(DIDEVTYPE_JOYSTICK, enum_ff_joysticks, &s, DIEDFL_FORCEFEEDBACK | DIEDFL_ATTACHEDONLY);
if(hr==DIERR_INVALIDPARAM) {
if (s.count > 0) {
hr = di_joystick_obj->EnumDevices(DIDEVTYPE_JOYSTICK, enum_ff_joysticks, &s,
DIEDFL_FORCEFEEDBACK | DIEDFL_ATTACHEDONLY);
if (hr == DIERR_INVALIDPARAM) {
OutputDebugString("Bad parm\n");
}
if (FAILED(hr)) {
@@ -638,11 +607,9 @@ int di_detect_joysticks(int cur_joy, CComboBox *box)
return s.count;
}
void CJoystickTab::OnBtnDetect()
{
void CJoystickTab::OnBtnDetect() {
// TODO: Add your control notification handler code here
//int cur_stick, i;
// int cur_stick, i;
int selected_stick;
HWND hwnd;
@@ -652,7 +619,7 @@ void CJoystickTab::OnBtnDetect()
// Display the scanning window
m_MsgDlg.m_ScanningMsg.LoadString(IDS_JOYSTICKTAB_SCANNING);
m_MsgDlg.m_WaitMsg.LoadString(IDS_PLEASE_WAIT_MSG);
m_MsgDlg.Create(IDD_MSG_DLG,this);
m_MsgDlg.Create(IDD_MSG_DLG, this);
m_MsgDlg.ShowWindow(SW_SHOW);
m_MsgDlg.UpdateData(FALSE);
@@ -663,12 +630,12 @@ void CJoystickTab::OnBtnDetect()
m_MsgDlg.DestroyWindow();
// Take the first joystick (if one exists)
if(Num_joysticks>1)
selected_stick=1; // First joystick in list
if (Num_joysticks > 1)
selected_stick = 1; // First joystick in list
else
selected_stick=0; // None
selected_stick = 0; // None
/*
/*
// Clear the list
m_joystick_list.ResetContent();
@@ -684,7 +651,7 @@ void CJoystickTab::OnBtnDetect()
// Set the joystick selection
m_joystick_list.SetCurSel(selected_stick);
*/
*/
// Display the primary joystick name in the text box
GetDlgItem(IDC_PRIMARY_JOYSTICK_TEXT)->SetWindowText(joystick_data[selected_stick].name);
@@ -700,30 +667,27 @@ void CJoystickTab::OnBtnDetect()
}
// Enable or disable the FF checkbox
GetDlgItem(IDC_FF_ENABLED,&hwnd);
GetDlgItem(IDC_FF_ENABLED, &hwnd);
#ifdef DEMO
::EnableWindow(hwnd, FALSE);
#else
::EnableWindow(hwnd, joystick_data[selected_stick].FF_capable);
#endif
UpdateData(FALSE);
}
void CJoystickTab::OnSelchangeJoystickList()
{
void CJoystickTab::OnSelchangeJoystickList() {
// TODO: Add your control notification handler code here
int index;
HWND hwnd;
// Get the new joystick list position
index=m_joystick_list.GetCurSel();
index = m_joystick_list.GetCurSel();
// Enable or disable the FF checkbox
if(index>=0 && index<Num_joysticks) {
if (index >= 0 && index < Num_joysticks) {
m_ff_enabled.SetCheck(joystick_data[index].FF_capable);
GetDlgItem(IDC_FF_ENABLED,&hwnd);
GetDlgItem(IDC_FF_ENABLED, &hwnd);
#ifdef DEMO
::EnableWindow(hwnd, FALSE);
#else
@@ -733,8 +697,7 @@ void CJoystickTab::OnSelchangeJoystickList()
}
}
BOOL CJoystickTab::OnHelpInfo(HELPINFO* pHelpInfo)
{
BOOL CJoystickTab::OnHelpInfo(HELPINFO *pHelpInfo) {
// TODO: Add your message handler code here and/or call default
#ifdef USE_HTML_HELP_SYSTEM
CWaitCursor wc;
@@ -746,12 +709,11 @@ BOOL CJoystickTab::OnHelpInfo(HELPINFO* pHelpInfo)
}
// Display the html help file
afx_msg LRESULT CJoystickTab::OnCommandHelp(WPARAM wParam, LPARAM lParam)
{
afx_msg LRESULT CJoystickTab::OnCommandHelp(WPARAM wParam, LPARAM lParam) {
#ifdef USE_HTML_HELP_SYSTEM
help_launch(JOYSTICKTAB_HELP);
return 1;
#else
return CPropertyPage::OnCommandHelp(wParam,lParam);
return CPropertyPage::OnCommandHelp(wParam, lParam);
#endif
}

View File

@@ -74,18 +74,17 @@ struct JoystickData {
/////////////////////////////////////////////////////////////////////////////
// CJoystickTab dialog
class CJoystickTab : public CPropertyPage
{
class CJoystickTab : public CPropertyPage {
DECLARE_DYNCREATE(CJoystickTab)
// Construction
// Construction
public:
CJoystickTab();
~CJoystickTab();
CMsgDlg m_MsgDlg;
// Dialog Data
// Dialog Data
//{{AFX_DATA(CJoystickTab)
enum { IDD = IDD_PROPPAGE_JOYSTICK };
CButton m_CHFlightEnabled;
@@ -96,16 +95,17 @@ public:
void DetectSticks();
// Overrides
// Overrides
// ClassWizard generate virtual function overrides
//{{AFX_VIRTUAL(CJoystickTab)
public:
public:
virtual void OnOK();
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
protected:
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CJoystickTab)
@@ -114,10 +114,9 @@ protected:
afx_msg void OnBtnDetect();
afx_msg void OnSelchangeJoystickList();
afx_msg LRESULT OnCommandHelp(WPARAM wParam, LPARAM lParam);
afx_msg BOOL OnHelpInfo(HELPINFO* pHelpInfo);
afx_msg BOOL OnHelpInfo(HELPINFO *pHelpInfo);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}

View File

@@ -87,19 +87,15 @@ static char THIS_FILE[] = __FILE__;
IMPLEMENT_DYNCREATE(CKeyboardTab, CPropertyPage)
CKeyboardTab::CKeyboardTab() : CPropertyPage(CKeyboardTab::IDD)
{
CKeyboardTab::CKeyboardTab() : CPropertyPage(CKeyboardTab::IDD) {
//{{AFX_DATA_INIT(CKeyboardTab)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
CKeyboardTab::~CKeyboardTab()
{
}
CKeyboardTab::~CKeyboardTab() {}
void CKeyboardTab::DoDataExchange(CDataExchange* pDX)
{
void CKeyboardTab::DoDataExchange(CDataExchange *pDX) {
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CKeyboardTab)
DDX_Control(pDX, IDC_FINDFAST_CHECK, m_FindFastCheck);
@@ -108,32 +104,30 @@ void CKeyboardTab::DoDataExchange(CDataExchange* pDX)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CKeyboardTab, CPropertyPage)
//{{AFX_MSG_MAP(CKeyboardTab)
ON_MESSAGE(WM_COMMANDHELP,OnCommandHelp)
ON_WM_HELPINFO()
//}}AFX_MSG_MAP
//{{AFX_MSG_MAP(CKeyboardTab)
ON_MESSAGE(WM_COMMANDHELP, OnCommandHelp)
ON_WM_HELPINFO()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CKeyboardTab message handlers
BOOL CKeyboardTab::OnInitDialog()
{
BOOL CKeyboardTab::OnInitDialog() {
CPropertyPage::OnInitDialog();
// Setup the language selection list
int lang_id;
AddLangToList(IDS_LANG_ENGLISH,LANGUAGE_ENGLISH);
AddLangToList(IDS_LANG_ENGLISH, LANGUAGE_ENGLISH);
#ifdef USE_MULTI_LANGUAGES
AddLangToList(IDS_LANG_FRENCH,LANGUAGE_FRENCH);
AddLangToList(IDS_LANG_GERMAN,LANGUAGE_GERMAN);
AddLangToList(IDS_LANG_FRENCH, LANGUAGE_FRENCH);
AddLangToList(IDS_LANG_GERMAN, LANGUAGE_GERMAN);
#ifdef ENABLE_ITALIAN
AddLangToList(IDS_LANG_ITALIAN,LANGUAGE_ITALIAN);
AddLangToList(IDS_LANG_ITALIAN, LANGUAGE_ITALIAN);
#endif
AddLangToList(IDS_LANG_SPANISH,LANGUAGE_SPANISH);
AddLangToList(IDS_LANG_SPANISH, LANGUAGE_SPANISH);
lang_id = os_config_read_uint(szSectionName, "LanguageType", LANGUAGE_ENGLISH);
#else
lang_id = LANGUAGE_ENGLISH;
@@ -142,7 +136,7 @@ BOOL CKeyboardTab::OnInitDialog()
SelectLangInList(lang_id);
// Disable the language selection box
if(!LanguageSelectionEnabled) {
if (!LanguageSelectionEnabled) {
m_LanguageCombo.EnableWindow(FALSE);
}
@@ -151,15 +145,15 @@ BOOL CKeyboardTab::OnInitDialog()
keyboard_type = os_config_read_string(szSectionName, "KeyboardType", "");
if (!stricmp(keyboard_type, KEYBOARD_FRENCH))
((CButton *) GetDlgItem(IDC_FRENCH_KEYBOARD))->SetCheck(1);
((CButton *)GetDlgItem(IDC_FRENCH_KEYBOARD))->SetCheck(1);
else if (!stricmp(keyboard_type, KEYBOARD_GERMAN))
((CButton *) GetDlgItem(IDC_GERMAN_KEYBOARD))->SetCheck(1);
((CButton *)GetDlgItem(IDC_GERMAN_KEYBOARD))->SetCheck(1);
else {
((CButton *) GetDlgItem(IDC_US_KEYBOARD))->SetCheck(1);
((CButton *)GetDlgItem(IDC_US_KEYBOARD))->SetCheck(1);
}
// Set the FindFast checkbox
if(os_config_read_uint(szSectionName, "FindFastDisable",1))
if (os_config_read_uint(szSectionName, "FindFastDisable", 1))
m_FindFastCheck.SetCheck(1);
else
m_FindFastCheck.SetCheck(0);
@@ -173,32 +167,33 @@ BOOL CKeyboardTab::OnInitDialog()
// EXCEPTION: OCX Property Pages should return FALSE
}
void CKeyboardTab::OnOK()
{
void CKeyboardTab::OnOK() {
// Get the selected language
int prev_lang_id, lang_id;
lang_id=GetSelectedLangFromList();
if(lang_id<0) lang_id=LANGUAGE_ENGLISH;
lang_id = GetSelectedLangFromList();
if (lang_id < 0)
lang_id = LANGUAGE_ENGLISH;
prev_lang_id=os_config_read_uint(szSectionName, "LanguageType", LANGUAGE_ENGLISH);
if(prev_lang_id!=lang_id) NewLanguageSelected=TRUE;
prev_lang_id = os_config_read_uint(szSectionName, "LanguageType", LANGUAGE_ENGLISH);
if (prev_lang_id != lang_id)
NewLanguageSelected = TRUE;
os_config_write_uint(szSectionName, "LanguageType", lang_id);
// Get the keyboard type
char *keyboard_type = KEYBOARD_US;
if ( ((CButton *) GetDlgItem(IDC_FRENCH_KEYBOARD))->GetCheck() == 1 )
if (((CButton *)GetDlgItem(IDC_FRENCH_KEYBOARD))->GetCheck() == 1)
keyboard_type = KEYBOARD_FRENCH;
else if ( ((CButton *) GetDlgItem(IDC_GERMAN_KEYBOARD))->GetCheck() == 1 )
else if (((CButton *)GetDlgItem(IDC_GERMAN_KEYBOARD))->GetCheck() == 1)
keyboard_type = KEYBOARD_GERMAN;
os_config_write_string(szSectionName, "KeyboardType", keyboard_type);
// save the findfast checkbox setting
if(m_FindFastCheck.GetCheck())
os_config_write_uint(szSectionName, "FindFastDisable",1);
if (m_FindFastCheck.GetCheck())
os_config_write_uint(szSectionName, "FindFastDisable", 1);
else
os_config_write_uint(szSectionName, "FindFastDisable",0);
os_config_write_uint(szSectionName, "FindFastDisable", 0);
// write the command line
CString command_line;
@@ -208,8 +203,7 @@ void CKeyboardTab::OnOK()
CPropertyPage::OnOK();
}
BOOL CKeyboardTab::OnHelpInfo(HELPINFO* pHelpInfo)
{
BOOL CKeyboardTab::OnHelpInfo(HELPINFO *pHelpInfo) {
// TODO: Add your message handler code here and/or call default
#ifdef USE_HTML_HELP_SYSTEM
CWaitCursor wc;
@@ -221,42 +215,40 @@ BOOL CKeyboardTab::OnHelpInfo(HELPINFO* pHelpInfo)
}
// Display the html help file
afx_msg LRESULT CKeyboardTab::OnCommandHelp(WPARAM wParam, LPARAM lParam)
{
afx_msg LRESULT CKeyboardTab::OnCommandHelp(WPARAM wParam, LPARAM lParam) {
#ifdef USE_HTML_HELP_SYSTEM
help_launch(KEYBOARDTAB_HELP);
return 1;
#else
return CPropertyPage::OnCommandHelp(wParam,lParam);
return CPropertyPage::OnCommandHelp(wParam, lParam);
#endif
}
bool CKeyboardTab::AddLangToList(int stringID, int langID)
{
bool CKeyboardTab::AddLangToList(int stringID, int langID) {
int index;
CString lang_string;
if(!lang_string.LoadString(stringID)) return FALSE;
if (!lang_string.LoadString(stringID))
return FALSE;
index=m_LanguageCombo.AddString(lang_string.GetBuffer(0));
if(index<0) return FALSE;
index = m_LanguageCombo.AddString(lang_string.GetBuffer(0));
if (index < 0)
return FALSE;
if(m_LanguageCombo.SetItemData(index,langID)==CB_ERR) return FALSE;
if (m_LanguageCombo.SetItemData(index, langID) == CB_ERR)
return FALSE;
return TRUE;
}
bool CKeyboardTab::SelectLangInList(int langID)
{
bool CKeyboardTab::SelectLangInList(int langID) {
int index, num_items;
num_items=m_LanguageCombo.GetCount();
for(index=0;index<num_items;index++) {
num_items = m_LanguageCombo.GetCount();
for (index = 0; index < num_items; index++) {
int data;
data=m_LanguageCombo.GetItemData(index);
if(data!=CB_ERR && data==langID) {
data = m_LanguageCombo.GetItemData(index);
if (data != CB_ERR && data == langID) {
m_LanguageCombo.SetCurSel(index);
return TRUE;
}
@@ -265,16 +257,16 @@ bool CKeyboardTab::SelectLangInList(int langID)
return FALSE;
}
int CKeyboardTab::GetSelectedLangFromList(void)
{
int CKeyboardTab::GetSelectedLangFromList(void) {
int index, data;
index=m_LanguageCombo.GetCurSel();
if(index<0) return(-1);
index = m_LanguageCombo.GetCurSel();
if (index < 0)
return (-1);
data=m_LanguageCombo.GetItemData(index);
if(data==CB_ERR) return(-1);
data = m_LanguageCombo.GetItemData(index);
if (data == CB_ERR)
return (-1);
return(data);
return (data);
}

View File

@@ -56,11 +56,10 @@
/////////////////////////////////////////////////////////////////////////////
// CKeyboardTab dialog
class CKeyboardTab : public CPropertyPage
{
class CKeyboardTab : public CPropertyPage {
DECLARE_DYNCREATE(CKeyboardTab)
// Construction
// Construction
public:
CKeyboardTab();
~CKeyboardTab();
@@ -69,7 +68,7 @@ public:
bool SelectLangInList(int langID);
int GetSelectedLangFromList(void);
// Dialog Data
// Dialog Data
//{{AFX_DATA(CKeyboardTab)
enum { IDD = IDD_PROPPAGE_KEYBOARD };
CButton m_FindFastCheck;
@@ -77,26 +76,25 @@ public:
CEdit m_CommandLineEdit;
//}}AFX_DATA
// Overrides
// Overrides
// ClassWizard generate virtual function overrides
//{{AFX_VIRTUAL(CKeyboardTab)
public:
public:
virtual void OnOK();
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
protected:
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CKeyboardTab)
virtual BOOL OnInitDialog();
afx_msg LRESULT OnCommandHelp(WPARAM wParam, LPARAM lParam);
afx_msg BOOL OnHelpInfo(HELPINFO* pHelpInfo);
afx_msg BOOL OnHelpInfo(HELPINFO *pHelpInfo);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// Label.cpp : implementation file
//
@@ -32,12 +32,11 @@ static char THIS_FILE[] = __FILE__;
/////////////////////////////////////////////////////////////////////////////
// CLabel
CLabel::CLabel()
{
CLabel::CLabel() {
m_crText = GetSysColor(COLOR_WINDOWTEXT);
m_hBrush = ::CreateSolidBrush(GetSysColor(COLOR_3DFACE));
::GetObject((HFONT)GetStockObject(DEFAULT_GUI_FONT),sizeof(m_lf),&m_lf);
::GetObject((HFONT)GetStockObject(DEFAULT_GUI_FONT), sizeof(m_lf), &m_lf);
m_font.CreateFontIndirect(&m_lf);
m_bTimer = FALSE;
@@ -49,82 +48,70 @@ CLabel::CLabel()
m_hwndBrush = ::CreateSolidBrush(GetSysColor(COLOR_3DFACE));
}
CLabel::~CLabel()
{
CLabel::~CLabel() {
m_font.DeleteObject();
::DeleteObject(m_hBrush);
}
CLabel& CLabel::SetText(const CString& strText)
{
CLabel &CLabel::SetText(const CString &strText) {
SetWindowText(strText);
return *this;
}
CLabel& CLabel::SetTextColor(COLORREF crText)
{
CLabel &CLabel::SetTextColor(COLORREF crText) {
m_crText = crText;
RedrawWindow();
return *this;
}
CLabel& CLabel::SetFontBold(BOOL bBold)
{
CLabel &CLabel::SetFontBold(BOOL bBold) {
m_lf.lfWeight = bBold ? FW_BOLD : FW_NORMAL;
ReconstructFont();
RedrawWindow();
return *this;
}
CLabel& CLabel::SetFontUnderline(BOOL bSet)
{
CLabel &CLabel::SetFontUnderline(BOOL bSet) {
m_lf.lfUnderline = bSet;
ReconstructFont();
RedrawWindow();
return *this;
}
CLabel& CLabel::SetFontItalic(BOOL bSet)
{
CLabel &CLabel::SetFontItalic(BOOL bSet) {
m_lf.lfItalic = bSet;
ReconstructFont();
RedrawWindow();
return *this;
}
CLabel& CLabel::SetSunken(BOOL bSet)
{
CLabel &CLabel::SetSunken(BOOL bSet) {
if (!bSet)
ModifyStyleEx(WS_EX_STATICEDGE,0,SWP_DRAWFRAME);
ModifyStyleEx(WS_EX_STATICEDGE, 0, SWP_DRAWFRAME);
else
ModifyStyleEx(0,WS_EX_STATICEDGE,SWP_DRAWFRAME);
ModifyStyleEx(0, WS_EX_STATICEDGE, SWP_DRAWFRAME);
return *this;
}
CLabel& CLabel::SetBorder(BOOL bSet)
{
CLabel &CLabel::SetBorder(BOOL bSet) {
if (!bSet)
ModifyStyle(WS_BORDER,0,SWP_DRAWFRAME);
ModifyStyle(WS_BORDER, 0, SWP_DRAWFRAME);
else
ModifyStyle(0,WS_BORDER,SWP_DRAWFRAME);
ModifyStyle(0, WS_BORDER, SWP_DRAWFRAME);
return *this;
}
CLabel& CLabel::SetFontSize(int nSize)
{
nSize*=-1;
CLabel &CLabel::SetFontSize(int nSize) {
nSize *= -1;
m_lf.lfHeight = nSize;
ReconstructFont();
RedrawWindow();
return *this;
}
CLabel& CLabel::SetBkColor(COLORREF crBkgnd)
{
CLabel &CLabel::SetBkColor(COLORREF crBkgnd) {
if (m_hBrush)
::DeleteObject(m_hBrush);
@@ -132,43 +119,37 @@ CLabel& CLabel::SetBkColor(COLORREF crBkgnd)
return *this;
}
CLabel& CLabel::SetFontName(const CString& strFont)
{
strcpy(m_lf.lfFaceName,strFont);
CLabel &CLabel::SetFontName(const CString &strFont) {
strcpy(m_lf.lfFaceName, strFont);
ReconstructFont();
RedrawWindow();
return *this;
}
BEGIN_MESSAGE_MAP(CLabel, CStatic)
//{{AFX_MSG_MAP(CLabel)
ON_WM_CTLCOLOR_REFLECT()
ON_WM_TIMER()
ON_WM_LBUTTONDOWN()
ON_WM_SETCURSOR()
//}}AFX_MSG_MAP
//{{AFX_MSG_MAP(CLabel)
ON_WM_CTLCOLOR_REFLECT()
ON_WM_TIMER()
ON_WM_LBUTTONDOWN()
ON_WM_SETCURSOR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLabel message handlers
HBRUSH CLabel::CtlColor(CDC* pDC, UINT nCtlColor)
{
HBRUSH CLabel::CtlColor(CDC *pDC, UINT nCtlColor) {
// TODO: Change any attributes of the DC here
// TODO: Return a non-NULL brush if the parent's handler should not be called
if (CTLCOLOR_STATIC == nCtlColor)
{
if (CTLCOLOR_STATIC == nCtlColor) {
pDC->SelectObject(&m_font);
pDC->SetTextColor(m_crText);
pDC->SetBkMode(TRANSPARENT);
}
if (m_Type == Background)
{
if (m_Type == Background) {
if (!m_bState)
return m_hwndBrush;
}
@@ -176,48 +157,41 @@ HBRUSH CLabel::CtlColor(CDC* pDC, UINT nCtlColor)
return m_hBrush;
}
void CLabel::ReconstructFont()
{
void CLabel::ReconstructFont() {
m_font.DeleteObject();
BOOL bCreated = m_font.CreateFontIndirect(&m_lf);
ASSERT(bCreated);
}
CLabel& CLabel::FlashText(BOOL bActivate)
{
if (m_bTimer)
{
CLabel &CLabel::FlashText(BOOL bActivate) {
if (m_bTimer) {
SetWindowText(m_strText);
KillTimer(1);
}
if (bActivate)
{
if (bActivate) {
GetWindowText(m_strText);
m_bState = FALSE;
m_bTimer = TRUE;
SetTimer(1,500,NULL);
SetTimer(1, 500, NULL);
m_Type = Text;
}
return *this;
}
CLabel& CLabel::FlashBackground(BOOL bActivate)
{
CLabel &CLabel::FlashBackground(BOOL bActivate) {
if (m_bTimer)
KillTimer(1);
if (bActivate)
{
if (bActivate) {
m_bState = FALSE;
m_bTimer = TRUE;
SetTimer(1,500,NULL);
SetTimer(1, 500, NULL);
m_Type = Background;
}
@@ -225,13 +199,10 @@ CLabel& CLabel::FlashBackground(BOOL bActivate)
return *this;
}
void CLabel::OnTimer(UINT nIDEvent)
{
void CLabel::OnTimer(UINT nIDEvent) {
m_bState = !m_bState;
switch (m_Type)
{
switch (m_Type) {
case Text:
if (m_bState)
SetWindowText("");
@@ -240,7 +211,7 @@ void CLabel::OnTimer(UINT nIDEvent)
break;
case Background:
InvalidateRect(NULL,FALSE);
InvalidateRect(NULL, FALSE);
UpdateWindow();
break;
}
@@ -248,32 +219,28 @@ void CLabel::OnTimer(UINT nIDEvent)
CStatic::OnTimer(nIDEvent);
}
CLabel& CLabel::SetLink(BOOL bLink)
{
CLabel &CLabel::SetLink(BOOL bLink) {
m_bLink = bLink;
if (bLink)
ModifyStyle(0,SS_NOTIFY);
ModifyStyle(0, SS_NOTIFY);
else
ModifyStyle(SS_NOTIFY,0);
ModifyStyle(SS_NOTIFY, 0);
return *this;
}
void CLabel::OnLButtonDown(UINT nFlags, CPoint point)
{
void CLabel::OnLButtonDown(UINT nFlags, CPoint point) {
CString strLink;
GetWindowText(strLink);
ShellExecute(NULL,"open",strLink,NULL,NULL,SW_SHOWNORMAL);
ShellExecute(NULL, "open", strLink, NULL, NULL, SW_SHOWNORMAL);
CStatic::OnLButtonDown(nFlags, point);
}
BOOL CLabel::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
if (m_hCursor)
{
BOOL CLabel::OnSetCursor(CWnd *pWnd, UINT nHitTest, UINT message) {
if (m_hCursor) {
::SetCursor(m_hCursor);
return TRUE;
}
@@ -281,9 +248,7 @@ BOOL CLabel::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
return CStatic::OnSetCursor(pWnd, nHitTest, message);
}
CLabel& CLabel::SetLinkCursor(HCURSOR hCursor)
{
CLabel &CLabel::SetLinkCursor(HCURSOR hCursor) {
m_hCursor = hCursor;
return *this;
}

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#if !defined(AFX_LABEL_H__A4EABEC5_2E8C_11D1_B79F_00805F9ECE10__INCLUDED_)
#define AFX_LABEL_H__A4EABEC5_2E8C_11D1_B79F_00805F9ECE10__INCLUDED_
@@ -27,29 +27,28 @@
/////////////////////////////////////////////////////////////////////////////
// CLabel window
enum FlashType {None, Text, Background };
enum FlashType { None, Text, Background };
class CLabel : public CStatic
{
// Construction
class CLabel : public CStatic {
// Construction
public:
CLabel();
CLabel& SetBkColor(COLORREF crBkgnd);
CLabel& SetTextColor(COLORREF crText);
CLabel& SetText(const CString& strText);
CLabel& SetFontBold(BOOL bBold);
CLabel& SetFontName(const CString& strFont);
CLabel& SetFontUnderline(BOOL bSet);
CLabel& SetFontItalic(BOOL bSet);
CLabel& SetFontSize(int nSize);
CLabel& SetSunken(BOOL bSet);
CLabel& SetBorder(BOOL bSet);
CLabel& FlashText(BOOL bActivate);
CLabel& FlashBackground(BOOL bActivate);
CLabel& SetLink(BOOL bLink);
CLabel& SetLinkCursor(HCURSOR hCursor);
CLabel &SetBkColor(COLORREF crBkgnd);
CLabel &SetTextColor(COLORREF crText);
CLabel &SetText(const CString &strText);
CLabel &SetFontBold(BOOL bBold);
CLabel &SetFontName(const CString &strFont);
CLabel &SetFontUnderline(BOOL bSet);
CLabel &SetFontItalic(BOOL bSet);
CLabel &SetFontSize(int nSize);
CLabel &SetSunken(BOOL bSet);
CLabel &SetBorder(BOOL bSet);
CLabel &FlashText(BOOL bActivate);
CLabel &FlashBackground(BOOL bActivate);
CLabel &SetLink(BOOL bLink);
CLabel &SetLinkCursor(HCURSOR hCursor);
// Attributes
// Attributes
public:
protected:
void ReconstructFont();
@@ -66,22 +65,22 @@ protected:
HCURSOR m_hCursor;
// Operations
public:
// Overrides
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CLabel)
//}}AFX_VIRTUAL
// Implementation
// Implementation
public:
virtual ~CLabel();
// Generated message map functions
protected:
//{{AFX_MSG(CLabel)
afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);
afx_msg HBRUSH CtlColor(CDC *pDC, UINT nCtlColor);
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
afx_msg BOOL OnSetCursor(CWnd *pWnd, UINT nHitTest, UINT message);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()

View File

@@ -310,5 +310,4 @@
#define REG_APP_NAME "Descent3";
#endif
#endif /* LAUNCHNAMES_H */

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/******************************************************************************\
* file : ListCtrlEx.cpp
@@ -55,25 +55,24 @@ static char THIS_FILE[] = __FILE__;
IMPLEMENT_DYNCREATE(CListCtrlEx, CListCtrl)
BEGIN_MESSAGE_MAP(CListCtrlEx, CListCtrl)
//{{AFX_MSG_MAP(CListCtrlEx)
ON_WM_PAINT()
ON_WM_SETFOCUS()
ON_WM_KILLFOCUS()
ON_WM_MOUSEMOVE()
ON_WM_LBUTTONDOWN()
ON_WM_KEYDOWN()
ON_WM_DESTROY()
//}}AFX_MSG_MAP
ON_MESSAGE(LVM_SETTEXTCOLOR, OnSetTextColor)
ON_MESSAGE(LVM_SETTEXTBKCOLOR, OnSetTextBkColor)
ON_MESSAGE(LVM_SETBKCOLOR, OnSetBkColor)
//{{AFX_MSG_MAP(CListCtrlEx)
ON_WM_PAINT()
ON_WM_SETFOCUS()
ON_WM_KILLFOCUS()
ON_WM_MOUSEMOVE()
ON_WM_LBUTTONDOWN()
ON_WM_KEYDOWN()
ON_WM_DESTROY()
//}}AFX_MSG_MAP
ON_MESSAGE(LVM_SETTEXTCOLOR, OnSetTextColor)
ON_MESSAGE(LVM_SETTEXTBKCOLOR, OnSetTextBkColor)
ON_MESSAGE(LVM_SETBKCOLOR, OnSetBkColor)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CListCtrlEx construction/destruction
CListCtrlEx::CListCtrlEx()
{
CListCtrlEx::CListCtrlEx() {
m_bFullRowSel = FALSE;
m_bClientWidthSel = TRUE;
@@ -82,23 +81,19 @@ CListCtrlEx::CListCtrlEx()
m_clrBkgnd = ::GetSysColor(COLOR_WINDOW);
}
CListCtrlEx::~CListCtrlEx()
{
}
CListCtrlEx::~CListCtrlEx() {}
// Make sure the control is owner drawn
BOOL CListCtrlEx::PreCreateWindow(CREATESTRUCT& cs)
{
BOOL CListCtrlEx::PreCreateWindow(CREATESTRUCT &cs) {
// default is report view and full row selection
cs.style &= ~LVS_TYPEMASK;
cs.style |= LVS_REPORT | LVS_OWNERDRAWFIXED;
m_bFullRowSel = TRUE;
return(CListCtrl::PreCreateWindow(cs));
return (CListCtrl::PreCreateWindow(cs));
}
BOOL CListCtrlEx::SetFullRowSel(BOOL bFullRowSel)
{
BOOL CListCtrlEx::SetFullRowSel(BOOL bFullRowSel) {
// no painting during change
LockWindowUpdate();
@@ -118,32 +113,28 @@ BOOL CListCtrlEx::SetFullRowSel(BOOL bFullRowSel)
// repaint changes
UnlockWindowUpdate();
return(bRet);
return (bRet);
}
BOOL CListCtrlEx::GetFullRowSel()
{
return(m_bFullRowSel);
}
BOOL CListCtrlEx::GetFullRowSel() { return (m_bFullRowSel); }
/////////////////////////////////////////////////////////////////////////////
// CListCtrlEx drawing
/*
* DrawItem() is called by the framework whenever an item needs to be drawn
* for owner drawn controls.
* Note:
* <UL>
* <LI>LVS_SHOWSELALWAYS: non owner drawn controls show an item is
* highlighted when the control does not have focus with a different
* highlight color is (usually gray). This is not supported for
* this control.
* </UL>
*/
* DrawItem() is called by the framework whenever an item needs to be drawn
* for owner drawn controls.
* Note:
* <UL>
* <LI>LVS_SHOWSELALWAYS: non owner drawn controls show an item is
* highlighted when the control does not have focus with a different
* highlight color is (usually gray). This is not supported for
* this control.
* </UL>
*/
void CListCtrlEx::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
void CListCtrlEx::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) {
CDC *pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
int iSavedDC = pDC->SaveDC(); // Save DC state
int iItem = lpDrawItemStruct->itemID;
@@ -156,10 +147,8 @@ void CListCtrlEx::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
lvi.stateMask = 0xFFFF; // get all state flags
GetItem(&lvi);
bool bHighlight = (
(lvi.state & LVIS_DROPHILITED) ||
((lvi.state & LVIS_SELECTED) && ((GetFocus() == this) || (GetStyle() & LVS_SHOWSELALWAYS)))
);
bool bHighlight = ((lvi.state & LVIS_DROPHILITED) ||
((lvi.state & LVIS_SELECTED) && ((GetFocus() == this) || (GetStyle() & LVS_SHOWSELALWAYS))));
// Get rectangles for drawing
CRect rcBounds;
@@ -174,76 +163,66 @@ void CListCtrlEx::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
// Labels are offset by a certain amount
// This offset is related to the width of a space character
int offset = pDC->GetTextExtent(_T(" "), 1 ).cx*2;
int offset = pDC->GetTextExtent(_T(" "), 1).cx * 2;
rcBounds.left = rcLabel.left;
CRect rcWnd;
GetClientRect(&rcWnd);
if(m_bClientWidthSel && rcBounds.right<rcWnd.right)
if (m_bClientWidthSel && rcBounds.right < rcWnd.right)
rcBounds.right = rcWnd.right;
// Draw the background
if(bHighlight)
{
if (bHighlight) {
pDC->SetTextColor(::GetSysColor(COLOR_HIGHLIGHTTEXT));
pDC->SetBkColor(::GetSysColor(COLOR_HIGHLIGHT));
pDC->FillRect(rcBounds, &CBrush(::GetSysColor(COLOR_HIGHLIGHT)));
}
else
{
} else {
pDC->FillRect(rcBounds, &CBrush(m_clrTextBk));
}
// Set clip region
rcItem.right = rcItem.left + GetColumnWidth(0);
/*
/*
CRgn rgn;
rgn.CreateRectRgnIndirect(&rcItem);
pDC->SelectClipRgn(&rgn);
rgn.DeleteObject();
*/
*/
// Draw state icon
if(lvi.state & LVIS_STATEIMAGEMASK)
{
int nImage = ((lvi.state & LVIS_STATEIMAGEMASK)>>12) - 1;
CImageList* pImageList = GetImageList(LVSIL_STATE);
if(pImageList)
{
pImageList->Draw(pDC, nImage,
CPoint(rcItem.left, rcItem.top), ILD_TRANSPARENT);
if (lvi.state & LVIS_STATEIMAGEMASK) {
int nImage = ((lvi.state & LVIS_STATEIMAGEMASK) >> 12) - 1;
CImageList *pImageList = GetImageList(LVSIL_STATE);
if (pImageList) {
pImageList->Draw(pDC, nImage, CPoint(rcItem.left, rcItem.top), ILD_TRANSPARENT);
}
}
// Draw normal and overlay icon
CImageList* pImageList = GetImageList(LVSIL_SMALL);
if(pImageList)
{
CImageList *pImageList = GetImageList(LVSIL_SMALL);
if (pImageList) {
UINT nOvlImageMask = lvi.state & LVIS_OVERLAYMASK;
pImageList->Draw(pDC, lvi.iImage,
CPoint(rcIcon.left, rcIcon.top),
(bHighlight?ILD_BLEND50:0) | ILD_TRANSPARENT | nOvlImageMask );
pImageList->Draw(pDC, lvi.iImage, CPoint(rcIcon.left, rcIcon.top),
(bHighlight ? ILD_BLEND50 : 0) | ILD_TRANSPARENT | nOvlImageMask);
}
// Draw item label - Column 0
rcLabel.left += offset/2-1;
rcLabel.left += offset / 2 - 1;
rcLabel.right -= offset;
pDC->DrawText(sLabel,-1,rcLabel,DT_LEFT | DT_SINGLELINE | DT_NOPREFIX
| DT_VCENTER | DT_END_ELLIPSIS);
pDC->DrawText(sLabel, -1, rcLabel, DT_LEFT | DT_SINGLELINE | DT_NOPREFIX | DT_VCENTER | DT_END_ELLIPSIS);
// Draw labels for remaining columns
LV_COLUMN lvc;
lvc.mask = LVCF_FMT | LVCF_WIDTH;
/*
// set clip region
/*
// set clip region
rcBounds.right = rcHighlight.right > rcBounds.right ? rcHighlight.right :
rcBounds.right;
rgn.CreateRectRgnIndirect(&rcBounds);
pDC->SelectClipRgn(&rgn);
*/
for(int nColumn = 1; GetColumn(nColumn, &lvc); nColumn++)
{
*/
for (int nColumn = 1; GetColumn(nColumn, &lvc); nColumn++) {
rcItem.left = rcItem.right;
rcItem.right += lvc.cx;
@@ -251,8 +230,7 @@ void CListCtrlEx::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
// Get the text justification
UINT nJustify = DT_LEFT;
switch(lvc.fmt & LVCFMT_JUSTIFYMASK)
{
switch (lvc.fmt & LVCFMT_JUSTIFYMASK) {
case LVCFMT_RIGHT:
nJustify = DT_RIGHT;
break;
@@ -267,8 +245,7 @@ void CListCtrlEx::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
rcLabel.left += offset;
rcLabel.right -= offset;
pDC->DrawText(sLabel, -1, rcLabel,
nJustify | DT_SINGLELINE | DT_NOPREFIX | DT_VCENTER | DT_END_ELLIPSIS);
pDC->DrawText(sLabel, -1, rcLabel, nJustify | DT_SINGLELINE | DT_NOPREFIX | DT_VCENTER | DT_END_ELLIPSIS);
}
// draw focus rectangle if item has focus
@@ -283,8 +260,7 @@ void CListCtrlEx::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
#ifdef _DEBUG
void CListCtrlEx::Dump(CDumpContext& dc) const
{
void CListCtrlEx::Dump(CDumpContext &dc) const {
CListCtrl::Dump(dc);
dc << "m_bFullRowSel = " << m_bFullRowSel;
@@ -293,22 +269,20 @@ void CListCtrlEx::Dump(CDumpContext& dc) const
#endif //_DEBUG
/**
* @param iRow [in] row of cell
* @param iColunm [in] column of cell
* @return Rectangle corresponding to the given cell.
*/
* @param iRow [in] row of cell
* @param iColunm [in] column of cell
* @return Rectangle corresponding to the given cell.
*/
CRect CListCtrlEx::GetCellRect(int iRow, int iColumn)const
{
CRect CListCtrlEx::GetCellRect(int iRow, int iColumn) const {
// Make sure that the ListView is in LVS_REPORT
if((GetStyle() & LVS_TYPEMASK) != LVS_REPORT)
return CRect(0,0,0,0);
if ((GetStyle() & LVS_TYPEMASK) != LVS_REPORT)
return CRect(0, 0, 0, 0);
// Get the number of columns
{
CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
CHeaderCtrl *pHeader = (CHeaderCtrl *)GetDlgItem(0);
int iColumnCount = pHeader->GetItemCount();
assert(iColumn < iColumnCount);
}
@@ -316,8 +290,7 @@ CRect CListCtrlEx::GetCellRect(int iRow, int iColumn)const
CRect rect;
GetItemRect(iRow, &rect, LVIR_BOUNDS);
// Now find the column
for(int colnum = 0; colnum < iColumn; colnum++)
{
for (int colnum = 0; colnum < iColumn; colnum++) {
rect.left += GetTrueColumnWidth(colnum);
}
@@ -326,20 +299,19 @@ CRect CListCtrlEx::GetCellRect(int iRow, int iColumn)const
RECT rectClient;
GetClientRect(&rectClient);
if(rect.right > rectClient.right)
if (rect.right > rectClient.right)
rect.right = rectClient.right;
return rect;
}
/**
* @author Mark Findlay
*/
* @author Mark Findlay
*/
CString CListCtrlEx::GetTrueItemText(int row, int col)const
{
CString CListCtrlEx::GetTrueItemText(int row, int col) const {
// Get the header control
CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
CHeaderCtrl *pHeader = (CHeaderCtrl *)GetDlgItem(0);
_ASSERTE(pHeader);
// get the current number of columns
@@ -347,17 +319,15 @@ CString CListCtrlEx::GetTrueItemText(int row, int col)const
// find the actual column requested. We will compare
// against hi.iOrder
for (int x=0; x< nCount; x++)
{
for (int x = 0; x < nCount; x++) {
HD_ITEM hi = {0};
hi.mask = HDI_ORDER;
BOOL bRet = pHeader->GetItem(x,&hi);
BOOL bRet = pHeader->GetItem(x, &hi);
_ASSERTE(bRet);
if (hi.iOrder == col)
{
if (hi.iOrder == col) {
// Found it, get the associated text
return GetItemText(row,x);
return GetItemText(row, x);
}
}
@@ -366,22 +336,20 @@ CString CListCtrlEx::GetTrueItemText(int row, int col)const
}
/**
* @author Mark Findlay
*/
* @author Mark Findlay
*/
int CListCtrlEx::GetTrueColumnWidth(int nCurrentPosition)const
{
CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
int CListCtrlEx::GetTrueColumnWidth(int nCurrentPosition) const {
CHeaderCtrl *pHeader = (CHeaderCtrl *)GetDlgItem(0);
_ASSERTE(pHeader);
int nCount = pHeader->GetItemCount();
for (int x=0; x< nCount; x++)
{
for (int x = 0; x < nCount; x++) {
HD_ITEM hi = {0};
hi.mask = HDI_WIDTH | HDI_ORDER;
BOOL bRet = pHeader->GetItem(x,&hi);
BOOL bRet = pHeader->GetItem(x, &hi);
_ASSERTE(bRet);
if (hi.iOrder == nCurrentPosition)
return hi.cxy;
@@ -391,46 +359,40 @@ int CListCtrlEx::GetTrueColumnWidth(int nCurrentPosition)const
return 0; // We would never fall through to here!
}
void CListCtrlEx::HideTitleTip()
{
m_titletip.ShowWindow(SW_HIDE);
}
void CListCtrlEx::HideTitleTip() { m_titletip.ShowWindow(SW_HIDE); }
/**
* @param point [in] point in client coordinates
* @param iRow [out] row containing the point
* @param iColunm [out] column containing the point
*
* @author Matthew Bells
*/
* @param point [in] point in client coordinates
* @param iRow [out] row containing the point
* @param iColunm [out] column containing the point
*
* @author Matthew Bells
*/
bool CListCtrlEx::HitTestRowCol(CPoint& point, int& iRow, int& iColumn)const
{
bool CListCtrlEx::HitTestRowCol(CPoint &point, int &iRow, int &iColumn) const {
// Make sure that the ListView is in LVS_REPORT
if((GetStyle() & LVS_TYPEMASK) != LVS_REPORT)
if ((GetStyle() & LVS_TYPEMASK) != LVS_REPORT)
return false;
int iPosX = point.x;
iRow = HitTest(point);
// Get the number of columns
CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
CHeaderCtrl *pHeader = (CHeaderCtrl *)GetDlgItem(0);
int iColumnCount = pHeader->GetItemCount();
for(iColumn = 0; iColumn < iColumnCount; ++iColumn)
{
for (iColumn = 0; iColumn < iColumnCount; ++iColumn) {
iPosX -= GetTrueColumnWidth(iColumn);
if(iPosX < 0)
if (iPosX < 0)
break;
}
if(iColumn == iColumnCount)
if (iColumn == iColumnCount)
iColumn = -1;
return (iRow != -1 && iColumn != -1);
}
void CListCtrlEx::RepaintSelectedItems()
{
void CListCtrlEx::RepaintSelectedItems() {
CRect rcItem;
CRect rcLabel;
@@ -438,8 +400,7 @@ void CListCtrlEx::RepaintSelectedItems()
int iItem = GetNextItem(-1, LVNI_FOCUSED);
if(iItem != -1)
{
if (iItem != -1) {
GetItemRect(iItem, rcItem, LVIR_BOUNDS);
GetItemRect(iItem, rcLabel, LVIR_LABEL);
rcItem.left = rcLabel.left;
@@ -449,11 +410,8 @@ void CListCtrlEx::RepaintSelectedItems()
// Invalidate selected items depending on LVS_SHOWSELALWAYS
if(!(GetStyle() & LVS_SHOWSELALWAYS))
{
for(iItem = GetNextItem(-1, LVNI_SELECTED);
iItem != -1; iItem = GetNextItem(iItem, LVNI_SELECTED))
{
if (!(GetStyle() & LVS_SHOWSELALWAYS)) {
for (iItem = GetNextItem(-1, LVNI_SELECTED); iItem != -1; iItem = GetNextItem(iItem, LVNI_SELECTED)) {
GetItemRect(iItem, rcItem, LVIR_BOUNDS);
GetItemRect(iItem, rcLabel, LVIR_LABEL);
rcItem.left = rcLabel.left;
@@ -468,22 +426,19 @@ void CListCtrlEx::RepaintSelectedItems()
/////////////////////////////////////////////////////////////////////////////
// CListCtrlEx message handlers
void CListCtrlEx::OnDestroy()
{
void CListCtrlEx::OnDestroy() {
m_titletip.DestroyWindow();
CListCtrl::OnDestroy();
}
void CListCtrlEx::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
void CListCtrlEx::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) {
inherited::OnChar(nChar, nRepCnt, nFlags);
HideTitleTip();
SendSelChangedNotification();
}
void CListCtrlEx::OnKillFocus(CWnd* pNewWnd)
{
void CListCtrlEx::OnKillFocus(CWnd *pNewWnd) {
CListCtrl::OnKillFocus(pNewWnd);
// This should be hidden no matter if another control is getting focus
@@ -492,40 +447,33 @@ void CListCtrlEx::OnKillFocus(CWnd* pNewWnd)
// this really still has focus if one of its chilren (ie. the edit box)
// has focus
if(pNewWnd != NULL && pNewWnd->GetParent() == this)
if (pNewWnd != NULL && pNewWnd->GetParent() == this)
return;
// repaint items that should change appearance
if(m_bFullRowSel && (GetStyle() & LVS_TYPEMASK) == LVS_REPORT)
if (m_bFullRowSel && (GetStyle() & LVS_TYPEMASK) == LVS_REPORT)
RepaintSelectedItems();
}
void CListCtrlEx::OnLButtonDown(UINT nFlags, CPoint point)
{
void CListCtrlEx::OnLButtonDown(UINT nFlags, CPoint point) {
int iTest = GetKeyState(VK_LMENU);
// Shortcut to editing.
if((GetKeyState(VK_LMENU) & 0x8000) || (GetKeyState(VK_RMENU) & 0x8000))
{
if ((GetKeyState(VK_LMENU) & 0x8000) || (GetKeyState(VK_RMENU) & 0x8000)) {
int iRow;
int iColumn;
if(HitTestRowCol(point, iRow, iColumn))
{
if (HitTestRowCol(point, iRow, iColumn)) {
SetFocus();
PostMessage(LVM_EDITLABEL, (WPARAM)iRow, 0);
}
}
else
{
} else {
inherited::OnLButtonDown(nFlags, point);
ShowTitleTip(point); // Make sure TitleTip changes if needed.
SendSelChangedNotification();
}
}
void CListCtrlEx::OnMouseMove(UINT nFlags, CPoint point)
{
if( nFlags == 0 )
{
void CListCtrlEx::OnMouseMove(UINT nFlags, CPoint point) {
if (nFlags == 0) {
ShowTitleTip(point); // Make sure TitleTip changes if needed.
}
@@ -533,28 +481,24 @@ void CListCtrlEx::OnMouseMove(UINT nFlags, CPoint point)
}
/*
* When the regular list view control repaints an item, it repaints only the
* area occupied by defined columns. If the last column does not extend to the
* end of the client area, then the space to the right of the last column is
* not repainted. If we are highlighting the full row then this area also needs
* to be invalidated so that the code in DrawItem() can add or remove the
* highlighting from this area.
*/
* When the regular list view control repaints an item, it repaints only the
* area occupied by defined columns. If the last column does not extend to the
* end of the client area, then the space to the right of the last column is
* not repainted. If we are highlighting the full row then this area also needs
* to be invalidated so that the code in DrawItem() can add or remove the
* highlighting from this area.
*/
void CListCtrlEx::OnPaint()
{
void CListCtrlEx::OnPaint() {
// in full row select mode, we need to extend the clipping region
// so we can paint a selection all the way to the right
if (m_bClientWidthSel &&
(GetStyle() & LVS_TYPEMASK) == LVS_REPORT && GetFullRowSel())
{
if (m_bClientWidthSel && (GetStyle() & LVS_TYPEMASK) == LVS_REPORT && GetFullRowSel()) {
CRect rcAllLabels;
GetItemRect(0, rcAllLabels, LVIR_BOUNDS);
CRect rcClient;
GetClientRect(&rcClient);
if(rcAllLabels.right < rcClient.right)
{
if (rcAllLabels.right < rcClient.right) {
// need to call BeginPaint (in CPaintDC c-tor)
// to get correct clipping rect
CPaintDC dc(this);
@@ -562,7 +506,7 @@ void CListCtrlEx::OnPaint()
CRect rcClip;
dc.GetClipBox(rcClip);
rcClip.left = min(rcAllLabels.right-1, rcClip.left);
rcClip.left = min(rcAllLabels.right - 1, rcClip.left);
rcClip.right = rcClient.right;
InvalidateRect(rcClip, FALSE);
@@ -573,55 +517,49 @@ void CListCtrlEx::OnPaint()
CListCtrl::OnPaint();
}
LRESULT CListCtrlEx::OnSetBkColor(WPARAM wParam, LPARAM lParam)
{
LRESULT CListCtrlEx::OnSetBkColor(WPARAM wParam, LPARAM lParam) {
m_clrBkgnd = (COLORREF)lParam;
return(Default());
return (Default());
}
/*
* This is another step to mimic the default behaviour of the list view
* control. When the control loses focus, the focus rectangle around the
* selected (focus) item has to be removed. When the control gets back
* focus, then the focus rectangle has to be redrawn. Both these handlers
* call the RepaintSelectedItems() helper function.
*/
* This is another step to mimic the default behaviour of the list view
* control. When the control loses focus, the focus rectangle around the
* selected (focus) item has to be removed. When the control gets back
* focus, then the focus rectangle has to be redrawn. Both these handlers
* call the RepaintSelectedItems() helper function.
*/
void CListCtrlEx::OnSetFocus(CWnd* pOldWnd)
{
void CListCtrlEx::OnSetFocus(CWnd *pOldWnd) {
CListCtrl::OnSetFocus(pOldWnd);
// check if we are getting focus from label edit box
// if(pOldWnd!=NULL && pOldWnd->GetParent()==this)
// return;
// if(pOldWnd!=NULL && pOldWnd->GetParent()==this)
// return;
// repaint items that should change appearance
if(m_bFullRowSel && (GetStyle() & LVS_TYPEMASK)==LVS_REPORT)
if (m_bFullRowSel && (GetStyle() & LVS_TYPEMASK) == LVS_REPORT)
RepaintSelectedItems();
}
LRESULT CListCtrlEx::OnSetTextBkColor(WPARAM wParam, LPARAM lParam)
{
LRESULT CListCtrlEx::OnSetTextBkColor(WPARAM wParam, LPARAM lParam) {
m_clrTextBk = (COLORREF)lParam;
return(Default());
return (Default());
}
LRESULT CListCtrlEx::OnSetTextColor(WPARAM wParam, LPARAM lParam)
{
LRESULT CListCtrlEx::OnSetTextColor(WPARAM wParam, LPARAM lParam) {
m_clrText = (COLORREF)lParam;
return(Default());
return (Default());
}
void CListCtrlEx::PreSubclassWindow()
{
void CListCtrlEx::PreSubclassWindow() {
CListCtrl::PreSubclassWindow();
m_titletip.Create(this);
m_titletip.SetBackground(CBrush(GetBkColor()));
}
void CListCtrlEx::SendSelChangedNotification()
{
void CListCtrlEx::SendSelChangedNotification() {
NMHDR nmh;
nmh.hwndFrom = *this;
nmh.idFrom = GetDlgCtrlID();
@@ -629,13 +567,11 @@ void CListCtrlEx::SendSelChangedNotification()
GetParent()->SendMessage(WM_NOTIFY, GetDlgCtrlID(), (LPARAM)&nmh);
}
void CListCtrlEx::ShowTitleTip(CPoint point)
{
void CListCtrlEx::ShowTitleTip(CPoint point) {
int iRow;
int iCol;
if(HitTestRowCol(point, iRow, iCol))
{
if (HitTestRowCol(point, iRow, iCol)) {
CRect cellrect = GetCellRect(iRow, iCol);
// offset is equal to TextExtent of 2 space characters.
// Make sure you have the right font selected into the
@@ -650,22 +586,19 @@ void CListCtrlEx::ShowTitleTip(CPoint point)
offset = rcLabel.left - cellrect.left + offset / 2 - 1;
}*/
if(iCol == 0) // TBD: test this with IE4
if (iCol == 0) // TBD: test this with IE4
cellrect.left -= 2; // Does it also move the first column???
cellrect.top--;
if(GetItemState(iRow, LVIS_SELECTED))
{
if (GetItemState(iRow, LVIS_SELECTED)) {
m_titletip.SetBkColor(::GetSysColor(COLOR_HIGHLIGHT));
m_titletip.SetTextColor(::GetSysColor(COLOR_HIGHLIGHTTEXT));
}
else
{
} else {
m_titletip.SetBkColor(m_clrTextBk);
m_titletip.SetTextColor(m_clrText);
}
m_titletip.Show(cellrect, GetTrueItemText(iRow, iCol), offset-1);
m_titletip.Show(cellrect, GetTrueItemText(iRow, iCol), offset - 1);
}
}

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/******************************************************************************\
* file : ListCtrl.h
@@ -32,28 +32,27 @@
#define LVNU_SELCHANGED 0x1000
/**
* A super CListControl.
* <P>features:
* <UL>
* <LI>Title Tip item expantion
* <LI>full row selection
* <LI>notifies parent selection has changed
* <LI>
* </UL>
*/
* A super CListControl.
* <P>features:
* <UL>
* <LI>Title Tip item expantion
* <LI>full row selection
* <LI>notifies parent selection has changed
* <LI>
* </UL>
*/
class CListCtrlEx : public CListCtrl
{
class CListCtrlEx : public CListCtrl {
typedef CListCtrl inherited;
DECLARE_DYNCREATE(CListCtrlEx)
// Construction
// Construction
public:
CListCtrlEx();
virtual ~CListCtrlEx();
// Attributes
// Attributes
protected:
BOOL m_bFullRowSel;
BOOL m_bClientWidthSel;
@@ -62,28 +61,29 @@ public:
BOOL SetFullRowSel(BOOL bFillRowSel);
BOOL GetFullRowSel();
// Overrides
// Overrides
protected:
virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CListCtrlEx)
public:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
public:
virtual BOOL PreCreateWindow(CREATESTRUCT &cs);
protected:
virtual void PreSubclassWindow();
//}}AFX_VIRTUAL
// Implementation
// Implementation
public:
#ifdef _DEBUG
virtual void Dump(CDumpContext& dc) const;
virtual void Dump(CDumpContext &dc) const;
#endif
protected:
void RepaintSelectedItems();
// Implementation - list view colors
// Implementation - list view colors
COLORREF m_clrText;
COLORREF m_clrTextBk;
COLORREF m_clrBkgnd;
@@ -93,22 +93,21 @@ protected:
afx_msg LRESULT OnSetTextBkColor(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnSetBkColor(WPARAM wParam, LPARAM lParam);
bool HitTestRowCol(CPoint& point, int& iRow, int& iColumn)const;
CRect GetCellRect(int iRow, int iColumn)const;
bool HitTestRowCol(CPoint &point, int &iRow, int &iColumn) const;
CRect GetCellRect(int iRow, int iColumn) const;
int GetTrueColumnWidth(int nCurrentPosition)const;
CString GetTrueItemText(int row, int col)const;
int GetTrueColumnWidth(int nCurrentPosition) const;
CString GetTrueItemText(int row, int col) const;
void HideTitleTip();
void SendSelChangedNotification();
void ShowTitleTip(CPoint point);
// Generated message map functions
// Generated message map functions
protected:
//{{AFX_MSG(CListCtrlEx)
afx_msg void OnPaint();
afx_msg void OnSetFocus(CWnd* pOldWnd);
afx_msg void OnKillFocus(CWnd* pNewWnd);
afx_msg void OnSetFocus(CWnd *pOldWnd);
afx_msg void OnKillFocus(CWnd *pNewWnd);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// MOTDDlg.cpp : implementation file
//
@@ -34,42 +34,35 @@ static char THIS_FILE[] = __FILE__;
/////////////////////////////////////////////////////////////////////////////
// CMOTDDlg dialog
CMOTDDlg::CMOTDDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMOTDDlg::IDD, pParent)
{
CMOTDDlg::CMOTDDlg(CWnd *pParent /*=NULL*/) : CDialog(CMOTDDlg::IDD, pParent) {
//{{AFX_DATA_INIT(CMOTDDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CMOTDDlg::DoDataExchange(CDataExchange* pDX)
{
void CMOTDDlg::DoDataExchange(CDataExchange *pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMOTDDlg)
DDX_Control(pDX, IDC_LIST1, m_TextList);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMOTDDlg, CDialog)
//{{AFX_MSG_MAP(CMOTDDlg)
ON_WM_SHOWWINDOW()
//}}AFX_MSG_MAP
//{{AFX_MSG_MAP(CMOTDDlg)
ON_WM_SHOWWINDOW()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMOTDDlg message handlers
BOOL CMOTDDlg::OnInitDialog()
{
BOOL CMOTDDlg::OnInitDialog() {
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_TextList.ResetContent();
if(!ParseMOTDFile())
if (!ParseMOTDFile())
return FALSE;
m_TextList.SetTopIndex(0);
@@ -78,21 +71,19 @@ BOOL CMOTDDlg::OnInitDialog()
// EXCEPTION: OCX Property Pages should return FALSE
}
// Reads the message of the day text into the list box
BOOL CMOTDDlg::ParseMOTDFile(void)
{
char filebuffer[_MAX_PATH+1];
BOOL CMOTDDlg::ParseMOTDFile(void) {
char filebuffer[_MAX_PATH + 1];
FILE *f;
f = fopen(MOTD_LOC_FNAME, "rt");
if(f == NULL){
if (f == NULL) {
return FALSE;
}
while (!feof(f)) {
fgets(filebuffer, _MAX_PATH, f);
if(strlen(filebuffer)>0 && filebuffer[strlen(filebuffer) - 1] == '\n')
if (strlen(filebuffer) > 0 && filebuffer[strlen(filebuffer) - 1] == '\n')
filebuffer[strlen(filebuffer) - 1] = '\0';
m_TextList.AddString(filebuffer);
}
@@ -101,12 +92,11 @@ BOOL CMOTDDlg::ParseMOTDFile(void)
return TRUE;
}
void CMOTDDlg::OnShowWindow(BOOL bShow, UINT nStatus)
{
void CMOTDDlg::OnShowWindow(BOOL bShow, UINT nStatus) {
CDialog::OnShowWindow(bShow, nStatus);
// TODO: Add your message handler code here
//if(bShow==TRUE && nStatus==SW_PARENTOPENING) {
// if(bShow==TRUE && nStatus==SW_PARENTOPENING) {
// OutputDebugString("Update dlg has opened\n");
//}
}

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#if !defined(AFX_MOTDDLG_H__C5900F80_3B79_11D2_8CBD_00A0C96ED60D__INCLUDED_)
#define AFX_MOTDDLG_H__C5900F80_3B79_11D2_8CBD_00A0C96ED60D__INCLUDED_
@@ -28,30 +28,27 @@
/////////////////////////////////////////////////////////////////////////////
// CMOTDDlg dialog
class CMOTDDlg : public CDialog
{
// Construction
class CMOTDDlg : public CDialog {
// Construction
public:
CMOTDDlg(CWnd* pParent = NULL); // standard constructor
CMOTDDlg(CWnd *pParent = NULL); // standard constructor
BOOL ParseMOTDFile(void);
// Dialog Data
// Dialog Data
//{{AFX_DATA(CMOTDDlg)
enum { IDD = IDD_MOTD_DIALOG };
CListBox m_TextList;
//}}AFX_DATA
// Overrides
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMOTDDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
protected:
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CMOTDDlg)
virtual BOOL OnInitDialog();

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// MessageWindowDlg.cpp : implementation file
//
@@ -35,19 +35,14 @@ CMessageWindowDlg *message_window;
/////////////////////////////////////////////////////////////////////////////
// CMessageWindowDlg dialog
CMessageWindowDlg::CMessageWindowDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMessageWindowDlg::IDD, pParent)
{
CMessageWindowDlg::CMessageWindowDlg(CWnd *pParent /*=NULL*/) : CDialog(CMessageWindowDlg::IDD, pParent) {
//{{AFX_DATA_INIT(CMessageWindowDlg)
m_WndMsgMain = _T("");
m_WndMsgStatus = _T("");
//}}AFX_DATA_INIT
}
void CMessageWindowDlg::DoDataExchange(CDataExchange* pDX)
{
void CMessageWindowDlg::DoDataExchange(CDataExchange *pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMessageWindowDlg)
DDX_Text(pDX, IDC_WND_MSG_MAIN, m_WndMsgMain);
@@ -55,26 +50,23 @@ void CMessageWindowDlg::DoDataExchange(CDataExchange* pDX)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMessageWindowDlg, CDialog)
//{{AFX_MSG_MAP(CMessageWindowDlg)
ON_BN_CLICKED(IDC_BTN_CANCEL, OnBtnCancel)
//}}AFX_MSG_MAP
//{{AFX_MSG_MAP(CMessageWindowDlg)
ON_BN_CLICKED(IDC_BTN_CANCEL, OnBtnCancel)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMessageWindowDlg message handlers
void CMessageWindowDlg::OnBtnCancel()
{
void CMessageWindowDlg::OnBtnCancel() {
// TODO: Add your control notification handler code here
// Dim the button once pressed
HWND hwnd;
GetDlgItem(IDC_BTN_CANCEL,&hwnd);
::EnableWindow(hwnd,FALSE);
GetDlgItem(IDC_BTN_CANCEL, &hwnd);
::EnableWindow(hwnd, FALSE);
// Mark cancel pressed global variable
CancelPressed=TRUE;
CancelPressed = TRUE;
}

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#if !defined(AFX_MESSAGEWINDOWDLG_H__65671E22_38F7_11D2_8CBD_00A0C96ED60D__INCLUDED_)
#define AFX_MESSAGEWINDOWDLG_H__65671E22_38F7_11D2_8CBD_00A0C96ED60D__INCLUDED_
@@ -25,34 +25,30 @@
// MessageWindowDlg.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CMessageWindowDlg dialog
class CMessageWindowDlg : public CDialog
{
// Construction
class CMessageWindowDlg : public CDialog {
// Construction
public:
CMessageWindowDlg(CWnd* pParent = NULL); // standard constructor
CMessageWindowDlg(CWnd *pParent = NULL); // standard constructor
// Dialog Data
// Dialog Data
//{{AFX_DATA(CMessageWindowDlg)
enum { IDD = IDD_MESSAGE_WINDOW };
CString m_WndMsgMain;
CString m_WndMsgStatus;
//}}AFX_DATA
// Overrides
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMessageWindowDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
protected:
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CMessageWindowDlg)
afx_msg void OnBtnCancel();

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// MsgDlg.cpp : implementation file
//
@@ -32,19 +32,14 @@ static char THIS_FILE[] = __FILE__;
/////////////////////////////////////////////////////////////////////////////
// CMsgDlg dialog
CMsgDlg::CMsgDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMsgDlg::IDD, pParent)
{
CMsgDlg::CMsgDlg(CWnd *pParent /*=NULL*/) : CDialog(CMsgDlg::IDD, pParent) {
//{{AFX_DATA_INIT(CMsgDlg)
m_ScanningMsg = _T("");
m_WaitMsg = _T("");
//}}AFX_DATA_INIT
}
void CMsgDlg::DoDataExchange(CDataExchange* pDX)
{
void CMsgDlg::DoDataExchange(CDataExchange *pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMsgDlg)
DDX_Text(pDX, IDC_SCANNING_TEXT, m_ScanningMsg);
@@ -52,11 +47,10 @@ void CMsgDlg::DoDataExchange(CDataExchange* pDX)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMsgDlg, CDialog)
//{{AFX_MSG_MAP(CMsgDlg)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
//{{AFX_MSG_MAP(CMsgDlg)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#if !defined(AFX_MSGDLG_H__E14B21A1_5F9C_11D2_A4E0_00A0C96ED60D__INCLUDED_)
#define AFX_MSGDLG_H__E14B21A1_5F9C_11D2_A4E0_00A0C96ED60D__INCLUDED_
@@ -28,30 +28,27 @@
/////////////////////////////////////////////////////////////////////////////
// CMsgDlg dialog
class CMsgDlg : public CDialog
{
// Construction
class CMsgDlg : public CDialog {
// Construction
public:
CMsgDlg(CWnd* pParent = NULL); // standard constructor
CMsgDlg(CWnd *pParent = NULL); // standard constructor
// Dialog Data
// Dialog Data
//{{AFX_DATA(CMsgDlg)
enum { IDD = IDD_MSG_DLG };
CString m_ScanningMsg;
CString m_WaitMsg;
//}}AFX_DATA
// Overrides
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMsgDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
protected:
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CMsgDlg)
// NOTE: the ClassWizard will add member functions here

View File

@@ -84,64 +84,58 @@ static char THIS_FILE[] = __FILE__;
IMPLEMENT_DYNCREATE(CNetworkTab, CPropertyPage)
CNetworkTab::CNetworkTab() : CPropertyPage(CNetworkTab::IDD)
{
CNetworkTab::CNetworkTab() : CPropertyPage(CNetworkTab::IDD) {
//{{AFX_DATA_INIT(CNetworkTab)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
CNetworkTab::~CNetworkTab()
{
}
CNetworkTab::~CNetworkTab() {}
void CNetworkTab::DoDataExchange(CDataExchange* pDX)
{
void CNetworkTab::DoDataExchange(CDataExchange *pDX) {
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CNetworkTab)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CNetworkTab, CPropertyPage)
//{{AFX_MSG_MAP(CNetworkTab)
ON_BN_CLICKED(IDC_DIALUP, OnDialup)
ON_BN_CLICKED(IDC_LAN, OnLan)
ON_BN_CLICKED(IDC_NONE, OnNone)
ON_MESSAGE(WM_COMMANDHELP,OnCommandHelp)
ON_WM_HELPINFO()
//}}AFX_MSG_MAP
//{{AFX_MSG_MAP(CNetworkTab)
ON_BN_CLICKED(IDC_DIALUP, OnDialup)
ON_BN_CLICKED(IDC_LAN, OnLan)
ON_BN_CLICKED(IDC_NONE, OnNone)
ON_MESSAGE(WM_COMMANDHELP, OnCommandHelp)
ON_WM_HELPINFO()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CNetworkTab message handlers
void CNetworkTab::OnOK()
{
void CNetworkTab::OnOK() {
// TODO: Add your specialized code here and/or call the base class
char *internet_connection = CONNECTION_NONE;
char *connection_speed = CONNECTION_SPEED_28K;
if ( ((CButton *) GetDlgItem(IDC_DIALUP))->GetCheck() == 1 )
if (((CButton *)GetDlgItem(IDC_DIALUP))->GetCheck() == 1)
internet_connection = CONNECTION_DIALUP;
else if ( ((CButton *) GetDlgItem(IDC_LAN))->GetCheck() == 1 )
else if (((CButton *)GetDlgItem(IDC_LAN))->GetCheck() == 1)
internet_connection = CONNECTION_LAN;
os_config_write_string(szSectionName, "NetworkConnection", internet_connection);
// deal with the connection speed
if ( ((CButton *) GetDlgItem(IDC_FAST_CONNECTION))->GetCheck() == 1 )
if (((CButton *)GetDlgItem(IDC_FAST_CONNECTION))->GetCheck() == 1)
connection_speed = CONNECTION_SPEED_FAST;
else if ( ((CButton *) GetDlgItem(IDC_CABLE_CONNECTION))->GetCheck() == 1 )
else if (((CButton *)GetDlgItem(IDC_CABLE_CONNECTION))->GetCheck() == 1)
connection_speed = CONNECTION_SPEED_CABLE;
else if ( ((CButton *) GetDlgItem(IDC_SINGLE_ISDN_CONNECTION))->GetCheck() == 1 )
else if (((CButton *)GetDlgItem(IDC_SINGLE_ISDN_CONNECTION))->GetCheck() == 1)
connection_speed = CONNECTION_SPEED_SISDN;
else if ( ((CButton *) GetDlgItem(IDC_56K_CONNECTION))->GetCheck() == 1 )
else if (((CButton *)GetDlgItem(IDC_56K_CONNECTION))->GetCheck() == 1)
connection_speed = CONNECTION_SPEED_56K;
else if ( ((CButton *) GetDlgItem(IDC_33K_CONNECTION))->GetCheck() == 1 )
else if (((CButton *)GetDlgItem(IDC_33K_CONNECTION))->GetCheck() == 1)
connection_speed = CONNECTION_SPEED_33K;
else if ( ((CButton *) GetDlgItem(IDC_28K_CONNECTION))->GetCheck() == 1 )
else if (((CButton *)GetDlgItem(IDC_28K_CONNECTION))->GetCheck() == 1)
connection_speed = CONNECTION_SPEED_28K;
os_config_write_string(szSectionName, "ConnectionSpeed", connection_speed);
@@ -149,8 +143,7 @@ void CNetworkTab::OnOK()
CPropertyPage::OnOK();
}
BOOL CNetworkTab::OnInitDialog()
{
BOOL CNetworkTab::OnInitDialog() {
CPropertyPage::OnInitDialog();
// TODO: Add extra initialization here
@@ -158,73 +151,68 @@ BOOL CNetworkTab::OnInitDialog()
internet_connection = os_config_read_string(szSectionName, "NetworkConnection", CONNECTION_DIALUP);
if (!stricmp(internet_connection, CONNECTION_DIALUP))
((CButton *) GetDlgItem(IDC_DIALUP))->SetCheck(1);
((CButton *)GetDlgItem(IDC_DIALUP))->SetCheck(1);
else if (!stricmp(internet_connection, CONNECTION_LAN))
((CButton *) GetDlgItem(IDC_LAN))->SetCheck(1);
((CButton *)GetDlgItem(IDC_LAN))->SetCheck(1);
else {
((CButton *) GetDlgItem(IDC_NONE))->SetCheck(1);
((CButton *)GetDlgItem(IDC_NONE))->SetCheck(1);
EnableSpeedGroup(FALSE);
}
// set up the connect speed radio buttons
connection_speed = os_config_read_string(szSectionName, "ConnectionSpeed", CONNECTION_SPEED_56K);
if ( !stricmp(connection_speed, CONNECTION_SPEED_FAST) )
((CButton *) GetDlgItem(IDC_FAST_CONNECTION))->SetCheck(1);
else if ( !stricmp(connection_speed, CONNECTION_SPEED_CABLE) )
((CButton *) GetDlgItem(IDC_CABLE_CONNECTION))->SetCheck(1);
else if ( !stricmp(connection_speed, CONNECTION_SPEED_SISDN) )
((CButton *) GetDlgItem(IDC_SINGLE_ISDN_CONNECTION))->SetCheck(1);
else if ( !stricmp(connection_speed, CONNECTION_SPEED_56K) )
((CButton *) GetDlgItem(IDC_56K_CONNECTION))->SetCheck(1);
else if ( !stricmp(connection_speed, CONNECTION_SPEED_33K) )
((CButton *) GetDlgItem(IDC_33K_CONNECTION))->SetCheck(1);
if (!stricmp(connection_speed, CONNECTION_SPEED_FAST))
((CButton *)GetDlgItem(IDC_FAST_CONNECTION))->SetCheck(1);
else if (!stricmp(connection_speed, CONNECTION_SPEED_CABLE))
((CButton *)GetDlgItem(IDC_CABLE_CONNECTION))->SetCheck(1);
else if (!stricmp(connection_speed, CONNECTION_SPEED_SISDN))
((CButton *)GetDlgItem(IDC_SINGLE_ISDN_CONNECTION))->SetCheck(1);
else if (!stricmp(connection_speed, CONNECTION_SPEED_56K))
((CButton *)GetDlgItem(IDC_56K_CONNECTION))->SetCheck(1);
else if (!stricmp(connection_speed, CONNECTION_SPEED_33K))
((CButton *)GetDlgItem(IDC_33K_CONNECTION))->SetCheck(1);
else
((CButton *) GetDlgItem(IDC_28K_CONNECTION))->SetCheck(1);
((CButton *)GetDlgItem(IDC_28K_CONNECTION))->SetCheck(1);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CNetworkTab::EnableSpeedGroup(bool bEnable)
{
void CNetworkTab::EnableSpeedGroup(bool bEnable) {
HWND hwnd;
GetDlgItem(IDC_28K_CONNECTION,&hwnd);
::EnableWindow(hwnd,bEnable);
GetDlgItem(IDC_33K_CONNECTION,&hwnd);
::EnableWindow(hwnd,bEnable);
GetDlgItem(IDC_56K_CONNECTION,&hwnd);
::EnableWindow(hwnd,bEnable);
GetDlgItem(IDC_SINGLE_ISDN_CONNECTION,&hwnd);
::EnableWindow(hwnd,bEnable);
GetDlgItem(IDC_CABLE_CONNECTION,&hwnd);
::EnableWindow(hwnd,bEnable);
GetDlgItem(IDC_FAST_CONNECTION,&hwnd);
::EnableWindow(hwnd,bEnable);
GetDlgItem(IDC_CONNECT_SPEED_GROUP,&hwnd);
::EnableWindow(hwnd,bEnable);
GetDlgItem(IDC_28K_CONNECTION, &hwnd);
::EnableWindow(hwnd, bEnable);
GetDlgItem(IDC_33K_CONNECTION, &hwnd);
::EnableWindow(hwnd, bEnable);
GetDlgItem(IDC_56K_CONNECTION, &hwnd);
::EnableWindow(hwnd, bEnable);
GetDlgItem(IDC_SINGLE_ISDN_CONNECTION, &hwnd);
::EnableWindow(hwnd, bEnable);
GetDlgItem(IDC_CABLE_CONNECTION, &hwnd);
::EnableWindow(hwnd, bEnable);
GetDlgItem(IDC_FAST_CONNECTION, &hwnd);
::EnableWindow(hwnd, bEnable);
GetDlgItem(IDC_CONNECT_SPEED_GROUP, &hwnd);
::EnableWindow(hwnd, bEnable);
}
void CNetworkTab::OnDialup()
{
void CNetworkTab::OnDialup() {
// TODO: Add your control notification handler code here
EnableSpeedGroup(TRUE);
}
void CNetworkTab::OnLan()
{
void CNetworkTab::OnLan() {
// TODO: Add your control notification handler code here
EnableSpeedGroup(TRUE);
}
void CNetworkTab::OnNone()
{
void CNetworkTab::OnNone() {
// TODO: Add your control notification handler code here
EnableSpeedGroup(FALSE);
}
BOOL CNetworkTab::OnHelpInfo(HELPINFO* pHelpInfo)
{
BOOL CNetworkTab::OnHelpInfo(HELPINFO *pHelpInfo) {
// TODO: Add your message handler code here and/or call default
#ifdef USE_HTML_HELP_SYSTEM
CWaitCursor wc;
@@ -236,13 +224,11 @@ BOOL CNetworkTab::OnHelpInfo(HELPINFO* pHelpInfo)
}
// Display the html help file
afx_msg LRESULT CNetworkTab::OnCommandHelp(WPARAM wParam, LPARAM lParam)
{
afx_msg LRESULT CNetworkTab::OnCommandHelp(WPARAM wParam, LPARAM lParam) {
#ifdef USE_HTML_HELP_SYSTEM
help_launch(NETWORKTAB_HELP);
return 1;
#else
return CPropertyPage::OnCommandHelp(wParam,lParam);
return CPropertyPage::OnCommandHelp(wParam, lParam);
#endif
}

View File

@@ -47,34 +47,33 @@
/////////////////////////////////////////////////////////////////////////////
// CNetworkTab dialog
class CNetworkTab : public CPropertyPage
{
class CNetworkTab : public CPropertyPage {
DECLARE_DYNCREATE(CNetworkTab)
// Construction
// Construction
public:
CNetworkTab();
~CNetworkTab();
void EnableSpeedGroup(bool bEnable);
// Dialog Data
// Dialog Data
//{{AFX_DATA(CNetworkTab)
enum { IDD = IDD_PROPPAGE_NETWORK };
// NOTE - ClassWizard will add data members here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_DATA
// Overrides
// Overrides
// ClassWizard generate virtual function overrides
//{{AFX_VIRTUAL(CNetworkTab)
public:
public:
virtual void OnOK();
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
protected:
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CNetworkTab)
@@ -83,10 +82,9 @@ protected:
afx_msg void OnLan();
afx_msg void OnNone();
afx_msg LRESULT OnCommandHelp(WPARAM wParam, LPARAM lParam);
afx_msg BOOL OnHelpInfo(HELPINFO* pHelpInfo);
afx_msg BOOL OnHelpInfo(HELPINFO *pHelpInfo);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}

View File

@@ -72,32 +72,31 @@ char *szSectionName = NULL; // Don't use a section name for the launcher
// Removes a value from to the INI file. Passing
// name=NULL will delete the section.
void os_config_remove( char *section, char *name )
{
void os_config_remove(char *section, char *name) {
HKEY hKey = NULL;
DWORD dwDisposition;
char keyname[1024];
LONG lResult;
if ( section ) {
sprintf( keyname, "Software\\%s\\%s\\%s", szCompanyName, szAppName, section );
if (section) {
sprintf(keyname, "Software\\%s\\%s\\%s", szCompanyName, szAppName, section);
} else {
sprintf( keyname, "Software\\%s\\%s", szCompanyName, szAppName );
sprintf(keyname, "Software\\%s\\%s", szCompanyName, szAppName);
}
// remove the value
if ( !name ) {
if ( !section ) {
if (!name) {
if (!section) {
////mprintf( "Can't delete root key\n" );
goto Cleanup;
}
lResult = RegDeleteKey( HKEY_LOCAL_MACHINE, keyname );
if ( lResult != ERROR_SUCCESS ) {
lResult = RegDeleteKey(HKEY_LOCAL_MACHINE, keyname);
if (lResult != ERROR_SUCCESS) {
////mprintf( "Error removing registry key '%s'\n", name );
goto Cleanup;
}
} else {
lResult = RegCreateKeyEx( HKEY_LOCAL_MACHINE, // Where to add it
lResult = RegCreateKeyEx(HKEY_LOCAL_MACHINE, // Where to add it
keyname, // name of key
NULL, // DWORD reserved
"", // Object class
@@ -105,44 +104,41 @@ void os_config_remove( char *section, char *name )
KEY_ALL_ACCESS, // Allows all changes
NULL, // Default security attributes
&hKey, // Location to store key
&dwDisposition ); // Location to store status of key
&dwDisposition); // Location to store status of key
if ( lResult != ERROR_SUCCESS ) {
//mprintf( "Error opening registry key '%s'\n", keyname );
if (lResult != ERROR_SUCCESS) {
// mprintf( "Error opening registry key '%s'\n", keyname );
goto Cleanup;
}
lResult = RegDeleteValue( hKey, name );
if ( lResult != ERROR_SUCCESS ) {
//mprintf( "Error removing registry value '%s'\n", name );
lResult = RegDeleteValue(hKey, name);
if (lResult != ERROR_SUCCESS) {
// mprintf( "Error removing registry value '%s'\n", name );
goto Cleanup;
}
}
Cleanup:
if ( hKey )
if (hKey)
RegCloseKey(hKey);
}
// Writes a string to the INI file. If value is NULL,
// removes the string. Writing a NULL value to a NULL name will delete
// the section.
void os_config_write_string( char *section, char *name, char *value )
{
void os_config_write_string(char *section, char *name, char *value) {
HKEY hKey = NULL;
DWORD dwDisposition;
char keyname[1024];
LONG lResult;
if ( section ) {
sprintf( keyname, "Software\\%s\\%s\\%s", szCompanyName, szAppName, section );
if (section) {
sprintf(keyname, "Software\\%s\\%s\\%s", szCompanyName, szAppName, section);
} else {
sprintf( keyname, "Software\\%s\\%s", szCompanyName, szAppName );
sprintf(keyname, "Software\\%s\\%s", szCompanyName, szAppName);
}
lResult = RegCreateKeyEx( HKEY_LOCAL_MACHINE, // Where to add it
lResult = RegCreateKeyEx(HKEY_LOCAL_MACHINE, // Where to add it
keyname, // name of key
NULL, // DWORD reserved
"", // Object class
@@ -150,52 +146,49 @@ void os_config_write_string( char *section, char *name, char *value )
KEY_ALL_ACCESS, // Allows all changes
NULL, // Default security attributes
&hKey, // Location to store key
&dwDisposition ); // Location to store status of key
&dwDisposition); // Location to store status of key
if ( lResult != ERROR_SUCCESS ) {
//mprintf( "Error opening registry key '%s'\n", keyname );
if (lResult != ERROR_SUCCESS) {
// mprintf( "Error opening registry key '%s'\n", keyname );
goto Cleanup;
}
if ( !name ) {
//mprintf( "No variable name passed\n" );
if (!name) {
// mprintf( "No variable name passed\n" );
goto Cleanup;
}
lResult = RegSetValueEx( hKey, // Handle to key
lResult = RegSetValueEx(hKey, // Handle to key
name, // The values name
NULL, // DWORD reserved
REG_SZ, // null terminated string
(CONST BYTE *)value, // value to set
strlen(value) ); // How many bytes to set
strlen(value)); // How many bytes to set
if ( lResult != ERROR_SUCCESS ) {
//mprintf( "Error writing registry key '%s'\n", name );
if (lResult != ERROR_SUCCESS) {
// mprintf( "Error writing registry key '%s'\n", name );
goto Cleanup;
}
Cleanup:
if ( hKey )
if (hKey)
RegCloseKey(hKey);
}
// same as previous function except we don't use the application name to build up the keyname
void os_config_write_string2( char *section, char *name, char *value )
{
void os_config_write_string2(char *section, char *name, char *value) {
HKEY hKey = NULL;
DWORD dwDisposition;
char keyname[1024];
LONG lResult;
if ( section ) {
sprintf( keyname, "Software\\%s\\%s", szCompanyName, section );
if (section) {
sprintf(keyname, "Software\\%s\\%s", szCompanyName, section);
} else {
sprintf( keyname, "Software\\%s", szCompanyName );
sprintf(keyname, "Software\\%s", szCompanyName);
}
lResult = RegCreateKeyEx( HKEY_LOCAL_MACHINE, // Where to add it
lResult = RegCreateKeyEx(HKEY_LOCAL_MACHINE, // Where to add it
keyname, // name of key
NULL, // DWORD reserved
"", // Object class
@@ -203,52 +196,49 @@ void os_config_write_string2( char *section, char *name, char *value )
KEY_ALL_ACCESS, // Allows all changes
NULL, // Default security attributes
&hKey, // Location to store key
&dwDisposition ); // Location to store status of key
&dwDisposition); // Location to store status of key
if ( lResult != ERROR_SUCCESS ) {
//mprintf( "Error opening registry key '%s'\n", keyname );
if (lResult != ERROR_SUCCESS) {
// mprintf( "Error opening registry key '%s'\n", keyname );
goto Cleanup;
}
if ( !name ) {
//mprintf( "No variable name passed\n" );
if (!name) {
// mprintf( "No variable name passed\n" );
goto Cleanup;
}
lResult = RegSetValueEx( hKey, // Handle to key
lResult = RegSetValueEx(hKey, // Handle to key
name, // The values name
NULL, // DWORD reserved
REG_SZ, // null terminated string
(CONST BYTE *)value, // value to set
strlen(value) ); // How many bytes to set
strlen(value)); // How many bytes to set
if ( lResult != ERROR_SUCCESS ) {
//mprintf( "Error writing registry key '%s'\n", name );
if (lResult != ERROR_SUCCESS) {
// mprintf( "Error writing registry key '%s'\n", name );
goto Cleanup;
}
Cleanup:
if ( hKey )
if (hKey)
RegCloseKey(hKey);
}
// Writes an uint32_t to the INI file.
void os_config_write_uint( char *section, char *name, uint32_t value )
{
void os_config_write_uint(char *section, char *name, uint32_t value) {
HKEY hKey = NULL;
DWORD dwDisposition;
char keyname[1024];
LONG lResult;
if ( section ) {
sprintf( keyname, "Software\\%s\\%s\\%s", szCompanyName, szAppName, section );
if (section) {
sprintf(keyname, "Software\\%s\\%s\\%s", szCompanyName, szAppName, section);
} else {
sprintf( keyname, "Software\\%s\\%s", szCompanyName, szAppName );
sprintf(keyname, "Software\\%s\\%s", szCompanyName, szAppName);
}
lResult = RegCreateKeyEx( HKEY_LOCAL_MACHINE, // Where to add it
lResult = RegCreateKeyEx(HKEY_LOCAL_MACHINE, // Where to add it
keyname, // name of key
NULL, // DWORD reserved
"", // Object class
@@ -256,39 +246,35 @@ void os_config_write_uint( char *section, char *name, uint32_t value )
KEY_ALL_ACCESS, // Allows all changes
NULL, // Default security attributes
&hKey, // Location to store key
&dwDisposition ); // Location to store status of key
&dwDisposition); // Location to store status of key
if ( lResult != ERROR_SUCCESS ) {
//mprintf( "Error opening registry key '%s'\n", keyname );
if (lResult != ERROR_SUCCESS) {
// mprintf( "Error opening registry key '%s'\n", keyname );
goto Cleanup;
}
if ( !name ) {
//mprintf( "No variable name passed\n" );
if (!name) {
// mprintf( "No variable name passed\n" );
goto Cleanup;
}
lResult = RegSetValueEx( hKey, // Handle to key
lResult = RegSetValueEx(hKey, // Handle to key
name, // The values name
NULL, // DWORD reserved
REG_DWORD, // null terminated string
(CONST BYTE *)&value, // value to set
4 ); // How many bytes to set
4); // How many bytes to set
if ( lResult != ERROR_SUCCESS ) {
//mprintf( "Error writing registry key '%s'\n", name );
if (lResult != ERROR_SUCCESS) {
// mprintf( "Error writing registry key '%s'\n", name );
goto Cleanup;
}
Cleanup:
if ( hKey )
if (hKey)
RegCloseKey(hKey);
}
// Reads a string from the INI file. If default is passed,
// and the string isn't found, returns ptr to default otherwise
// returns NULL; Copy the return value somewhere before
@@ -297,208 +283,199 @@ Cleanup:
static char tmp_string_data[1024];
char * os_config_read_string( char *section, char *name, char *default_value )
{
char *os_config_read_string(char *section, char *name, char *default_value) {
HKEY hKey = NULL;
DWORD dwType, dwLen;
char keyname[1024];
LONG lResult;
if ( section ) {
sprintf( keyname, "Software\\%s\\%s\\%s", szCompanyName, szAppName, section );
if (section) {
sprintf(keyname, "Software\\%s\\%s\\%s", szCompanyName, szAppName, section);
} else {
sprintf( keyname, "Software\\%s\\%s", szCompanyName, szAppName );
sprintf(keyname, "Software\\%s\\%s", szCompanyName, szAppName);
}
lResult = RegOpenKeyEx( HKEY_LOCAL_MACHINE, // Where it is
lResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, // Where it is
keyname, // name of key
NULL, // DWORD reserved
KEY_QUERY_VALUE, // Allows all changes
&hKey ); // Location to store key
&hKey); // Location to store key
if ( lResult != ERROR_SUCCESS ) {
//mprintf( "Error opening registry key '%s'\n", keyname );
if (lResult != ERROR_SUCCESS) {
// mprintf( "Error opening registry key '%s'\n", keyname );
goto Cleanup;
}
if ( !name ) {
//mprintf( "No variable name passed\n" );
if (!name) {
// mprintf( "No variable name passed\n" );
goto Cleanup;
}
dwLen = 1024;
lResult = RegQueryValueEx( hKey, // Handle to key
lResult = RegQueryValueEx(hKey, // Handle to key
name, // The values name
NULL, // DWORD reserved
&dwType, // What kind it is
(uint8_t *)&tmp_string_data, // value to set
&dwLen ); // How many bytes to set
&dwLen); // How many bytes to set
if ( lResult != ERROR_SUCCESS ) {
//mprintf( "Error reading registry key '%s'\n", name );
if (lResult != ERROR_SUCCESS) {
// mprintf( "Error reading registry key '%s'\n", name );
goto Cleanup;
}
default_value = tmp_string_data;
Cleanup:
if ( hKey )
if (hKey)
RegCloseKey(hKey);
return default_value;
}
static char tmp_string_data_ex[1024];
char * os_config_read_string_ex( char *keyname, char *name, char *default_value )
{
char *os_config_read_string_ex(char *keyname, char *name, char *default_value) {
HKEY hKey = NULL;
DWORD dwType, dwLen;
LONG lResult;
lResult = RegOpenKeyEx( HKEY_LOCAL_MACHINE, // Where it is
lResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, // Where it is
keyname, // name of key
NULL, // DWORD reserved
KEY_QUERY_VALUE, // Allows all changes
&hKey ); // Location to store key
&hKey); // Location to store key
if ( lResult != ERROR_SUCCESS ) {
//mprintf( "Error opening registry key '%s'\n", keyname );
if (lResult != ERROR_SUCCESS) {
// mprintf( "Error opening registry key '%s'\n", keyname );
goto Cleanup;
}
if ( !name ) {
//mprintf( "No variable name passed\n" );
if (!name) {
// mprintf( "No variable name passed\n" );
goto Cleanup;
}
dwLen = 1024;
lResult = RegQueryValueEx( hKey, // Handle to key
lResult = RegQueryValueEx(hKey, // Handle to key
name, // The values name
NULL, // DWORD reserved
&dwType, // What kind it is
(uint8_t *)&tmp_string_data_ex, // value to set
&dwLen ); // How many bytes to set
&dwLen); // How many bytes to set
if ( lResult != ERROR_SUCCESS ) {
//mprintf( "Error reading registry key '%s'\n", name );
if (lResult != ERROR_SUCCESS) {
// mprintf( "Error reading registry key '%s'\n", name );
goto Cleanup;
}
default_value = tmp_string_data_ex;
Cleanup:
if ( hKey )
if (hKey)
RegCloseKey(hKey);
return default_value;
}
char * os_config_read_string2( char *section, char *name, char *default_value )
{
char *os_config_read_string2(char *section, char *name, char *default_value) {
HKEY hKey = NULL;
DWORD dwType, dwLen;
char keyname[1024];
LONG lResult;
if ( section ) {
sprintf( keyname, "Software\\%s\\%s", szCompanyName, section );
if (section) {
sprintf(keyname, "Software\\%s\\%s", szCompanyName, section);
} else {
sprintf( keyname, "Software\\%s", szCompanyName );
sprintf(keyname, "Software\\%s", szCompanyName);
}
lResult = RegOpenKeyEx( HKEY_LOCAL_MACHINE, // Where it is
lResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, // Where it is
keyname, // name of key
NULL, // DWORD reserved
KEY_QUERY_VALUE, // Allows all changes
&hKey ); // Location to store key
&hKey); // Location to store key
if ( lResult != ERROR_SUCCESS ) {
//mprintf( "Error opening registry key '%s'\n", keyname );
if (lResult != ERROR_SUCCESS) {
// mprintf( "Error opening registry key '%s'\n", keyname );
goto Cleanup;
}
if ( !name ) {
//mprintf( "No variable name passed\n" );
if (!name) {
// mprintf( "No variable name passed\n" );
goto Cleanup;
}
dwLen = 1024;
lResult = RegQueryValueEx( hKey, // Handle to key
lResult = RegQueryValueEx(hKey, // Handle to key
name, // The values name
NULL, // DWORD reserved
&dwType, // What kind it is
(uint8_t *)&tmp_string_data, // value to set
&dwLen ); // How many bytes to set
&dwLen); // How many bytes to set
if ( lResult != ERROR_SUCCESS ) {
//mprintf( "Error reading registry key '%s'\n", name );
if (lResult != ERROR_SUCCESS) {
// mprintf( "Error reading registry key '%s'\n", name );
goto Cleanup;
}
default_value = tmp_string_data;
Cleanup:
if ( hKey )
if (hKey)
RegCloseKey(hKey);
return default_value;
}
// Reads a string from the INI file. Default_value must
// be passed, and if 'name' isn't found, then returns default_value
uint32_t os_config_read_uint( char *section, char *name, uint32_t default_value )
{
uint32_t os_config_read_uint(char *section, char *name, uint32_t default_value) {
HKEY hKey = NULL;
DWORD dwType, dwLen;
char keyname[1024];
LONG lResult;
uint32_t tmp_val;
if ( section ) {
sprintf( keyname, "Software\\%s\\%s\\%s", szCompanyName, szAppName, section );
if (section) {
sprintf(keyname, "Software\\%s\\%s\\%s", szCompanyName, szAppName, section);
} else {
sprintf( keyname, "Software\\%s\\%s", szCompanyName, szAppName );
sprintf(keyname, "Software\\%s\\%s", szCompanyName, szAppName);
}
lResult = RegOpenKeyEx( HKEY_LOCAL_MACHINE, // Where it is
lResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, // Where it is
keyname, // name of key
NULL, // DWORD reserved
KEY_QUERY_VALUE, // Allows all changes
&hKey ); // Location to store key
&hKey); // Location to store key
if ( lResult != ERROR_SUCCESS ) {
//mprintf( "Error opening registry key '%s'\n", keyname );
if (lResult != ERROR_SUCCESS) {
// mprintf( "Error opening registry key '%s'\n", keyname );
goto Cleanup;
}
if ( !name ) {
//mprintf( "No variable name passed\n" );
if (!name) {
// mprintf( "No variable name passed\n" );
goto Cleanup;
}
dwLen = 4;
lResult = RegQueryValueEx( hKey, // Handle to key
lResult = RegQueryValueEx(hKey, // Handle to key
name, // The values name
NULL, // DWORD reserved
&dwType, // What kind it is
(uint8_t *)&tmp_val, // value to set
&dwLen ); // How many bytes to set
&dwLen); // How many bytes to set
if ( lResult != ERROR_SUCCESS ) {
//mprintf( "Error reading registry key '%s'\n", name );
if (lResult != ERROR_SUCCESS) {
// mprintf( "Error reading registry key '%s'\n", name );
goto Cleanup;
}
default_value = tmp_val;
Cleanup:
if ( hKey )
if (hKey)
RegCloseKey(hKey);
return default_value;

View File

@@ -48,11 +48,11 @@
#include "PsTypes.h"
void os_config_write_string( char *section, char *name, char *value );
char *os_config_read_string( char *section, char *name, char *default_value );
uint32_t os_config_read_uint( char *section, char *name, uint32_t default_value );
void os_config_write_uint( char *section, char *name, uint32_t value );
char *os_config_read_string_ex( char *keyname, char *name, char *default_value );
void os_config_write_string(char *section, char *name, char *value);
char *os_config_read_string(char *section, char *name, char *default_value);
uint32_t os_config_read_uint(char *section, char *name, uint32_t default_value);
void os_config_write_uint(char *section, char *name, uint32_t value);
char *os_config_read_string_ex(char *keyname, char *name, char *default_value);
extern char *szSectionName;

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// SetupPropSheet.cpp : implementation file
//
@@ -34,51 +34,43 @@ static char THIS_FILE[] = __FILE__;
IMPLEMENT_DYNAMIC(CSetupPropSheet, CPropertySheet)
CSetupPropSheet::CSetupPropSheet(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
:CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
{
}
CSetupPropSheet::CSetupPropSheet(UINT nIDCaption, CWnd *pParentWnd, UINT iSelectPage)
: CPropertySheet(nIDCaption, pParentWnd, iSelectPage) {}
CSetupPropSheet::CSetupPropSheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
:CPropertySheet(pszCaption, pParentWnd, iSelectPage)
{
}
CSetupPropSheet::~CSetupPropSheet()
{
}
CSetupPropSheet::CSetupPropSheet(LPCTSTR pszCaption, CWnd *pParentWnd, UINT iSelectPage)
: CPropertySheet(pszCaption, pParentWnd, iSelectPage) {}
CSetupPropSheet::~CSetupPropSheet() {}
BEGIN_MESSAGE_MAP(CSetupPropSheet, CPropertySheet)
//{{AFX_MSG_MAP(CSetupPropSheet)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
//{{AFX_MSG_MAP(CSetupPropSheet)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSetupPropSheet message handlers
BOOL CSetupPropSheet::OnInitDialog()
{
BOOL CSetupPropSheet::OnInitDialog() {
BOOL bResult = CPropertySheet::OnInitDialog();
// TODO: Add your specialized code here
HWND OK_btn = ::GetDlgItem(this->m_hWnd, IDOK);
if(OK_btn!=NULL) {
if (OK_btn != NULL) {
CString title;
title.LoadString(IDS_OK);
::SetWindowText(OK_btn, title.GetBuffer(0));
}
HWND Cancel_btn = ::GetDlgItem(this->m_hWnd, IDCANCEL);
if(Cancel_btn!=NULL) {
if (Cancel_btn != NULL) {
CString title;
title.LoadString(IDS_CANCEL);
::SetWindowText(Cancel_btn, title.GetBuffer(0));
}
HWND Help_btn = ::GetDlgItem(this->m_hWnd, IDHELP);
if(Help_btn!=NULL) {
if (Help_btn != NULL) {
CString title;
title.LoadString(IDS_HELP);
::SetWindowText(Help_btn, title.GetBuffer(0));

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#if !defined(AFX_SETUPPROPSHEET_H__00C45F60_1F5F_11D3_A4E1_00A0C96ED60D__INCLUDED_)
#define AFX_SETUPPROPSHEET_H__00C45F60_1F5F_11D3_A4E1_00A0C96ED60D__INCLUDED_
@@ -28,29 +28,26 @@
/////////////////////////////////////////////////////////////////////////////
// CSetupPropSheet
class CSetupPropSheet : public CPropertySheet
{
class CSetupPropSheet : public CPropertySheet {
DECLARE_DYNAMIC(CSetupPropSheet)
// Construction
// Construction
public:
CSetupPropSheet(UINT nIDCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);
CSetupPropSheet(LPCTSTR pszCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);
CSetupPropSheet(UINT nIDCaption, CWnd *pParentWnd = NULL, UINT iSelectPage = 0);
CSetupPropSheet(LPCTSTR pszCaption, CWnd *pParentWnd = NULL, UINT iSelectPage = 0);
// Attributes
// Attributes
public:
// Operations
// Operations
public:
// Overrides
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CSetupPropSheet)
public:
public:
virtual BOOL OnInitDialog();
//}}AFX_VIRTUAL
// Implementation
// Implementation
public:
virtual ~CSetupPropSheet();

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// SiteSelectDlg.cpp : implementation file
//
@@ -39,78 +39,68 @@ static char THIS_FILE[] = __FILE__;
#define SITE_ADDRESS_COLUMN_WIDTH 0.4
#define SITE_LOCATION_COLUMN_WIDTH 0.3
/////////////////////////////////////////////////////////////////////////////
// CSiteSelectDlg dialog
CSiteSelectDlg::CSiteSelectDlg(CWnd* pParent /*=NULL*/)
: CDialog(CSiteSelectDlg::IDD, pParent)
{
CSiteSelectDlg::CSiteSelectDlg(CWnd *pParent /*=NULL*/) : CDialog(CSiteSelectDlg::IDD, pParent) {
//{{AFX_DATA_INIT(CSiteSelectDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CSiteSelectDlg::DoDataExchange(CDataExchange* pDX)
{
void CSiteSelectDlg::DoDataExchange(CDataExchange *pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSiteSelectDlg)
DDX_Control(pDX, IDC_SITE_LIST, m_SiteList);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSiteSelectDlg, CDialog)
//{{AFX_MSG_MAP(CSiteSelectDlg)
//}}AFX_MSG_MAP
//{{AFX_MSG_MAP(CSiteSelectDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSiteSelectDlg message handlers
void CSiteSelectDlg::OnOK()
{
void CSiteSelectDlg::OnOK() {
// TODO: Add extra validation here
int num_items, j, flags;
// If no item is selected, return (user MUST select an item)
if(m_SiteList.GetSelectedCount()==0) {
LocalizedMessageBox(IDS_SITESELECTDLG_MUST_SELECT, IDS_SITESELECTDLG_SELECT_TITLE, MB_OK|MB_ICONEXCLAMATION);
if (m_SiteList.GetSelectedCount() == 0) {
LocalizedMessageBox(IDS_SITESELECTDLG_MUST_SELECT, IDS_SITESELECTDLG_SELECT_TITLE, MB_OK | MB_ICONEXCLAMATION);
return;
}
// How many items in the control list?
num_items=m_SiteList.GetItemCount();
num_items = m_SiteList.GetItemCount();
// scan the item list for the selected item
chosen_site=NO_SITE_CHOSEN;
j=0;
while(j<num_items) {
chosen_site = NO_SITE_CHOSEN;
j = 0;
while (j < num_items) {
flags=m_SiteList.GetItemState(j,LVIS_SELECTED);
if(flags & LVIS_SELECTED)
chosen_site=j;
flags = m_SiteList.GetItemState(j, LVIS_SELECTED);
if (flags & LVIS_SELECTED)
chosen_site = j;
j++;
}
// If no site is selected, get outta here
if(chosen_site==NO_SITE_CHOSEN) {
LocalizedMessageBox(IDS_SITESELECTDLG_MUST_SELECT, IDS_SITESELECTDLG_SELECT_TITLE, MB_OK|MB_ICONEXCLAMATION);
if (chosen_site == NO_SITE_CHOSEN) {
LocalizedMessageBox(IDS_SITESELECTDLG_MUST_SELECT, IDS_SITESELECTDLG_SELECT_TITLE, MB_OK | MB_ICONEXCLAMATION);
return;
}
// Create the selected download path
sprintf(download_path,"%s%s",site_entries[chosen_site].url,site_entries[chosen_site].path);
sprintf(download_path, "%s%s", site_entries[chosen_site].url, site_entries[chosen_site].path);
CDialog::OnOK();
}
BOOL CSiteSelectDlg::OnInitDialog()
{
BOOL CSiteSelectDlg::OnInitDialog() {
CDialog::OnInitDialog();
// TODO: Add extra initialization here
@@ -118,96 +108,91 @@ BOOL CSiteSelectDlg::OnInitDialog()
// Setup the columns
column_name.LoadString(IDS_SITESELECTDLG_SITE_NAME);
m_SiteList.InsertColumn(SITE_NAME_COLUMN,column_name.GetBuffer(0),LVCFMT_LEFT,
-1,SITE_NAME_COLUMN);
m_SiteList.InsertColumn(SITE_NAME_COLUMN, column_name.GetBuffer(0), LVCFMT_LEFT, -1, SITE_NAME_COLUMN);
column_name.LoadString(IDS_SITESELECTDLG_SITE_ADDRESS);
m_SiteList.InsertColumn(SITE_ADDRESS_COLUMN,column_name.GetBuffer(0),LVCFMT_LEFT,
-1,SITE_ADDRESS_COLUMN);
m_SiteList.InsertColumn(SITE_ADDRESS_COLUMN, column_name.GetBuffer(0), LVCFMT_LEFT, -1, SITE_ADDRESS_COLUMN);
column_name.LoadString(IDS_SITESELECTDLG_SITE_LOCATION);
m_SiteList.InsertColumn(SITE_LOCATION_COLUMN,column_name.GetBuffer(0),LVCFMT_LEFT,
-1,SITE_LOCATION_COLUMN);
m_SiteList.InsertColumn(SITE_LOCATION_COLUMN, column_name.GetBuffer(0), LVCFMT_LEFT, -1, SITE_LOCATION_COLUMN);
SetColumnWidths();
// Init the site entries
m_SiteList.SetFullRowSel(TRUE);
m_SiteList.DeleteAllItems();
num_sites=0;
chosen_site=NO_SITE_CHOSEN;
download_path[0]='\0';
num_sites = 0;
chosen_site = NO_SITE_CHOSEN;
download_path[0] = '\0';
// Read in the site entry data
if(!ParseSiteFile()) {
if (!ParseSiteFile()) {
LocalizedMessageBox(IDS_SITESELECTDLG_PARSE_ERROR, IDS_SITESELECTDLG_SELECT_TITLE, MB_OK | MB_ICONERROR);
return FALSE;
}
m_SiteList.SetItemState(0,LVIS_SELECTED|LVIS_FOCUSED,LVIS_SELECTED|LVIS_FOCUSED);
m_SiteList.SetItemState(0, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
// Calculates column widths and sets them
void CSiteSelectDlg::SetColumnWidths(void)
{
void CSiteSelectDlg::SetColumnWidths(void) {
uint32_t w0, w1, w2;
RECT rect;
m_SiteList.GetClientRect(&rect);
w0=uint32_t(rect.right*SITE_NAME_COLUMN_WIDTH);
w1=uint32_t(rect.right*SITE_ADDRESS_COLUMN_WIDTH);
w2=uint32_t(rect.right*SITE_LOCATION_COLUMN_WIDTH);
w0 = uint32_t(rect.right * SITE_NAME_COLUMN_WIDTH);
w1 = uint32_t(rect.right * SITE_ADDRESS_COLUMN_WIDTH);
w2 = uint32_t(rect.right * SITE_LOCATION_COLUMN_WIDTH);
m_SiteList.SetColumnWidth(SITE_NAME_COLUMN,w0);
m_SiteList.SetColumnWidth(SITE_ADDRESS_COLUMN,w1);
m_SiteList.SetColumnWidth(SITE_LOCATION_COLUMN,w2);
m_SiteList.SetColumnWidth(SITE_NAME_COLUMN, w0);
m_SiteList.SetColumnWidth(SITE_ADDRESS_COLUMN, w1);
m_SiteList.SetColumnWidth(SITE_LOCATION_COLUMN, w2);
}
// Reads in site entries from the site info file,
// and adds them to the lists
BOOL CSiteSelectDlg::ParseSiteFile(void)
{
BOOL CSiteSelectDlg::ParseSiteFile(void) {
SITE_ENTRY site_entry;
char filebuffer[_MAX_PATH+1];
char filebuffer[_MAX_PATH + 1];
int field;
FILE *f;
f = fopen(SITES_LOC_FNAME, "rt");
if(f == NULL){
if (f == NULL) {
return FALSE;
}
field=0;
strcpy(filebuffer,"");
field = 0;
strcpy(filebuffer, "");
while (!feof(f)) {
fgets(filebuffer, _MAX_PATH, f);
if(strlen(filebuffer)>0 && filebuffer[strlen(filebuffer) - 1] == '\n')
if (strlen(filebuffer) > 0 && filebuffer[strlen(filebuffer) - 1] == '\n')
filebuffer[strlen(filebuffer) - 1] = '\0';
// if line is a comment, or empty, discard it
if(strlen(filebuffer)==0 || filebuffer[0]==SITE_FILE_COMMENT_CHAR)
if (strlen(filebuffer) == 0 || filebuffer[0] == SITE_FILE_COMMENT_CHAR)
continue;
switch(field) {
switch (field) {
case 0:
strcpy(site_entry.name,filebuffer);
strcpy(site_entry.name, filebuffer);
break;
case 1:
strcpy(site_entry.location,filebuffer);
strcpy(site_entry.location, filebuffer);
break;
case 2:
strcpy(site_entry.url,filebuffer);
strcpy(site_entry.url, filebuffer);
break;
case 3:
strcpy(site_entry.path,filebuffer);
strcpy(site_entry.path, filebuffer);
break;
}
field++;
if(field==4) {
if (field == 4) {
AddSiteEntry(&site_entry);
field=0;
field = 0;
}
}
fclose(f);
@@ -216,37 +201,35 @@ BOOL CSiteSelectDlg::ParseSiteFile(void)
}
// Adds an entry struct to the list array and the list control
BOOL CSiteSelectDlg::AddSiteEntry(SITE_ENTRY *entry)
{
BOOL CSiteSelectDlg::AddSiteEntry(SITE_ENTRY *entry) {
int index;
// Check if too many sites have been read in
if(num_sites>=MAX_SITES) return FALSE;
if (num_sites >= MAX_SITES)
return FALSE;
// Add the entry to the list control
index=m_SiteList.GetItemCount();
if((index=m_SiteList.InsertItem(index,entry->name))==-1)
index = m_SiteList.GetItemCount();
if ((index = m_SiteList.InsertItem(index, entry->name)) == -1)
OutputDebugString("Didn't work!");
m_SiteList.SetItem(index,SITE_ADDRESS_COLUMN,LVIF_TEXT,entry->url,0,0,0,0);
m_SiteList.SetItem(index,SITE_LOCATION_COLUMN,LVIF_TEXT,entry->location,0,0,0,0);
m_SiteList.SetItem(index, SITE_ADDRESS_COLUMN, LVIF_TEXT, entry->url, 0, 0, 0, 0);
m_SiteList.SetItem(index, SITE_LOCATION_COLUMN, LVIF_TEXT, entry->location, 0, 0, 0, 0);
// Add the entry to the list array
strcpy(site_entries[num_sites].name,entry->name);
strcpy(site_entries[num_sites].location,entry->location);
strcpy(site_entries[num_sites].url,entry->url);
strcpy(site_entries[num_sites].path,entry->path);
strcpy(site_entries[num_sites].name, entry->name);
strcpy(site_entries[num_sites].location, entry->location);
strcpy(site_entries[num_sites].url, entry->url);
strcpy(site_entries[num_sites].path, entry->path);
num_sites++;
return TRUE;
}
void CSiteSelectDlg::LocalizedMessageBox(UINT msgID, UINT titleID, UINT type /*=MB_OK*/)
{
void CSiteSelectDlg::LocalizedMessageBox(UINT msgID, UINT titleID, UINT type /*=MB_OK*/) {
CString msg, title;
msg.LoadString(msgID);
title.LoadString(titleID);
MessageBox(msg,title,type);
MessageBox(msg, title, type);
}

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#if !defined(AFX_SITESELECTDLG_H__65671E24_38F7_11D2_8CBD_00A0C96ED60D__INCLUDED_)
#define AFX_SITESELECTDLG_H__65671E24_38F7_11D2_8CBD_00A0C96ED60D__INCLUDED_
@@ -34,10 +34,10 @@
// Structure for the site entries
struct SITE_ENTRY {
char name[_MAX_PATH+1]; // The name/description of the site
char url[_MAX_PATH+1]; // Just the base http/ftp address
char location[_MAX_PATH+1]; // Where the site is located
char path[_MAX_PATH+1]; // The remote directory and patch filename
char name[_MAX_PATH + 1]; // The name/description of the site
char url[_MAX_PATH + 1]; // Just the base http/ftp address
char location[_MAX_PATH + 1]; // Where the site is located
char path[_MAX_PATH + 1]; // The remote directory and patch filename
};
#define NO_SITE_CHOSEN -1
@@ -45,38 +45,35 @@ struct SITE_ENTRY {
/////////////////////////////////////////////////////////////////////////////
// CSiteSelectDlg dialog
class CSiteSelectDlg : public CDialog
{
// Construction
class CSiteSelectDlg : public CDialog {
// Construction
public:
CSiteSelectDlg(CWnd* pParent = NULL); // standard constructor
CSiteSelectDlg(CWnd *pParent = NULL); // standard constructor
void SetColumnWidths(void);
BOOL AddSiteEntry(SITE_ENTRY *entry);
BOOL ParseSiteFile(void);
void LocalizedMessageBox(UINT msgID, UINT titleID, UINT type=MB_OK);
void LocalizedMessageBox(UINT msgID, UINT titleID, UINT type = MB_OK);
SITE_ENTRY site_entries[MAX_SITES]; // array of site entries
int num_sites; // the number of sites in memory
int chosen_site; // the index of the chosen site
char download_path[_MAX_PATH*2+1]; // the full patch download path
char download_path[_MAX_PATH * 2 + 1]; // the full patch download path
// Dialog Data
// Dialog Data
//{{AFX_DATA(CSiteSelectDlg)
enum { IDD = IDD_SITE_SELECTION_DIALOG };
CListCtrlEx m_SiteList;
//}}AFX_DATA
// Overrides
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CSiteSelectDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
protected:
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CSiteSelectDlg)
virtual void OnOK();

View File

@@ -109,54 +109,48 @@ static char THIS_FILE[] = __FILE__;
IMPLEMENT_DYNCREATE(CSpeedTab, CPropertyPage)
CSpeedTab::CSpeedTab() : CPropertyPage(CSpeedTab::IDD)
{
CSpeedTab::CSpeedTab() : CPropertyPage(CSpeedTab::IDD) {
//{{AFX_DATA_INIT(CSpeedTab)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_WriteDetailValues=FALSE;
m_WriteDetailValues = FALSE;
}
CSpeedTab::~CSpeedTab()
{
}
CSpeedTab::~CSpeedTab() {}
void CSpeedTab::DoDataExchange(CDataExchange* pDX)
{
void CSpeedTab::DoDataExchange(CDataExchange *pDX) {
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSpeedTab)
DDX_Control(pDX, IDC_SPEED_LIST, m_speed_list);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSpeedTab, CPropertyPage)
//{{AFX_MSG_MAP(CSpeedTab)
ON_BN_CLICKED(IDC_BTN_SPEED_DETECT, OnBtnSpeedDetect)
ON_MESSAGE(WM_COMMANDHELP,OnCommandHelp)
ON_WM_HELPINFO()
ON_CBN_SELCHANGE(IDC_SPEED_LIST, OnSelchangeSpeedList)
//}}AFX_MSG_MAP
//{{AFX_MSG_MAP(CSpeedTab)
ON_BN_CLICKED(IDC_BTN_SPEED_DETECT, OnBtnSpeedDetect)
ON_MESSAGE(WM_COMMANDHELP, OnCommandHelp)
ON_WM_HELPINFO()
ON_CBN_SELCHANGE(IDC_SPEED_LIST, OnSelchangeSpeedList)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSpeedTab message handlers
void CSpeedTab::OnOK()
{
void CSpeedTab::OnOK() {
// TODO: Add your specialized code here and/or call the base class
int cur_speed = m_speed_list.GetCurSel();
if ( (cur_speed < 0) || (cur_speed>CUSTOM_DETAIL)) {
if ((cur_speed < 0) || (cur_speed > CUSTOM_DETAIL)) {
cur_speed = 0;
}
os_config_write_uint(szSectionName, "PredefDetailSetting", cur_speed );
os_config_write_uint(szSectionName, "PredefDetailSetting", cur_speed);
// If the user has switched to a new default detail setting,
// then write out all the default detail levels to registry
if(m_WriteDetailValues) {
switch(cur_speed) {
if (m_WriteDetailValues) {
switch (cur_speed) {
case 0:
break;
case 1:
@@ -166,27 +160,26 @@ void CSpeedTab::OnOK()
case 3:
break;
}
m_WriteDetailValues=FALSE;
m_WriteDetailValues = FALSE;
}
// As long as they have viewed this page, they can get past the
// "set detail level" message when trying to play
DetailLevelConfigured=TRUE;
DetailLevelConfigured = TRUE;
CPropertyPage::OnOK();
}
BOOL CSpeedTab::OnInitDialog()
{
BOOL CSpeedTab::OnInitDialog() {
CPropertyPage::OnInitDialog();
// TODO: Add extra initialization here
// 0=low, 1=medium, 2=high, 3=very high
int cur_speed = os_config_read_uint(szSectionName, "PredefDetailSetting", MEDIUM_DETAIL );
int cur_speed = os_config_read_uint(szSectionName, "PredefDetailSetting", MEDIUM_DETAIL);
if ( cur_speed < 0 )
if (cur_speed < 0)
cur_speed = 0;
else if ( cur_speed > CUSTOM_DETAIL )
else if (cur_speed > CUSTOM_DETAIL)
cur_speed = VERY_HIGH_DETAIL;
m_speed_list.ResetContent();
@@ -194,22 +187,22 @@ BOOL CSpeedTab::OnInitDialog()
CString speed_type;
speed_type.LoadString(IDS_SPEEDTAB_LOW);
m_speed_list.InsertString( LOW_DETAIL, speed_type );
m_speed_list.InsertString(LOW_DETAIL, speed_type);
speed_type.LoadString(IDS_SPEEDTAB_MEDIUM);
m_speed_list.InsertString( MEDIUM_DETAIL, speed_type );
m_speed_list.InsertString(MEDIUM_DETAIL, speed_type);
speed_type.LoadString(IDS_SPEEDTAB_HIGH);
m_speed_list.InsertString( HIGH_DETAIL, speed_type );
m_speed_list.InsertString(HIGH_DETAIL, speed_type);
speed_type.LoadString(IDS_SPEEDTAB_VERY_HIGH);
m_speed_list.InsertString( VERY_HIGH_DETAIL, speed_type );
m_speed_list.InsertString(VERY_HIGH_DETAIL, speed_type);
if(cur_speed==CUSTOM_DETAIL) {
if (cur_speed == CUSTOM_DETAIL) {
speed_type.LoadString(IDS_SPEEDTAB_CUSTOM);
m_speed_list.InsertString( CUSTOM_DETAIL, speed_type );
m_speed_list.InsertString(CUSTOM_DETAIL, speed_type);
}
m_speed_list.SetCurSel(cur_speed);
m_WriteDetailValues=FALSE;
m_WriteDetailValues = FALSE;
// Blank out property entries so user can watch them fill up again
CString tmp_str;
@@ -217,19 +210,19 @@ BOOL CSpeedTab::OnInitDialog()
HWND hwnd;
tmp_str.LoadString(IDS_SPEEDTAB_NOT_DETECTED);
sprintf(tmp,"%s",tmp_str.GetBuffer(0));
GetDlgItem( IDC_CPU_TYPE, &hwnd );
::SetWindowText( hwnd, tmp );
GetDlgItem( IDC_CPU_SPEED, &hwnd );
::SetWindowText( hwnd, tmp );
GetDlgItem( IDC_TOTAL_RAM, &hwnd );
::SetWindowText( hwnd, tmp );
GetDlgItem( IDC_RAM_SPEED, &hwnd );
::SetWindowText( hwnd, tmp );
GetDlgItem( IDC_VRAM_SPEED, &hwnd );
::SetWindowText( hwnd, tmp );
GetDlgItem( IDC_3D_GRAPHICS_ACCELERATOR, &hwnd );
::SetWindowText( hwnd, tmp );
sprintf(tmp, "%s", tmp_str.GetBuffer(0));
GetDlgItem(IDC_CPU_TYPE, &hwnd);
::SetWindowText(hwnd, tmp);
GetDlgItem(IDC_CPU_SPEED, &hwnd);
::SetWindowText(hwnd, tmp);
GetDlgItem(IDC_TOTAL_RAM, &hwnd);
::SetWindowText(hwnd, tmp);
GetDlgItem(IDC_RAM_SPEED, &hwnd);
::SetWindowText(hwnd, tmp);
GetDlgItem(IDC_VRAM_SPEED, &hwnd);
::SetWindowText(hwnd, tmp);
GetDlgItem(IDC_3D_GRAPHICS_ACCELERATOR, &hwnd);
::SetWindowText(hwnd, tmp);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
@@ -239,8 +232,7 @@ BOOL CSpeedTab::OnInitDialog()
#define EMMS _asm _emit 0fh _asm _emit 077h
#define RTSC _asm _emit 0fh _asm _emit 031h
DWORD ReadClocks()
{
DWORD ReadClocks() {
DWORD count;
_asm {
@@ -250,12 +242,9 @@ DWORD ReadClocks()
return count;
}
// -----------------------------------------------------------------------
// Returns cpu type.
void detect_cpu(int *cpu, int *mmx, int *time_stamp_counter)
{
void detect_cpu(int *cpu, int *mmx, int *time_stamp_counter) {
BOOL retval = TRUE;
DWORD RegEDX;
DWORD RegEAX;
@@ -265,7 +254,6 @@ void detect_cpu(int *cpu, int *mmx, int *time_stamp_counter)
*mmx = 0;
*time_stamp_counter = 0;
// jmp is not allowed in try
_asm {
@@ -307,17 +295,15 @@ done_checking_cpuid:
pop eax
}
// RegEAX . Bits 11:8 is family
*cpu = (RegEAX >> 8) & 0xF;
//RegEAX . Bits 11:8 is family
*cpu = (RegEAX >>8) & 0xF;
if ( *cpu < 5 ) {
if (*cpu < 5) {
*cpu = 4; // processor does not support CPUID
*mmx = 0;
}
if (RegEDX & (1<<4) ) { // bit 4 is set for RTSC technology
if (RegEDX & (1 << 4)) { // bit 4 is set for RTSC technology
*time_stamp_counter = 1;
}
@@ -332,15 +318,16 @@ done_checking_cpuid:
} // try executing an MMX instruction "emms"
__except(EXCEPTION_EXECUTE_HANDLER) { retval = FALSE; }
__except (EXCEPTION_EXECUTE_HANDLER) {
retval = FALSE;
}
} else {
*mmx = 0; // processor supports CPUID but does not support MMX technology
return;
}
if ( retval == 0 ) {
if (retval == 0) {
// if retval == 0 here that means the processor has MMX technology but
// floating-point emulation is on; so MMX technology is unavailable
*mmx = 0; // processor supports CPUID but does not support MMX technology
@@ -352,8 +339,7 @@ done_checking_cpuid:
// --------------------------------------------------------------------------
void CSpeedTab::OnBtnSpeedDetect()
{
void CSpeedTab::OnBtnSpeedDetect() {
// TODO: Add your control notification handler code here
char tmp[1024];
CString tmp_str;
@@ -364,58 +350,56 @@ void CSpeedTab::OnBtnSpeedDetect()
// Blank out property entries so user can watch them fill up again
tmp_str.LoadString(IDS_SPEEDTAB_NOT_DETECTED);
sprintf(tmp,"%s",tmp_str.GetBuffer(0));
GetDlgItem( IDC_CPU_TYPE, &hwnd );
::SetWindowText( hwnd, tmp );
GetDlgItem( IDC_CPU_SPEED, &hwnd );
::SetWindowText( hwnd, tmp );
GetDlgItem( IDC_TOTAL_RAM, &hwnd );
::SetWindowText( hwnd, tmp );
GetDlgItem( IDC_RAM_SPEED, &hwnd );
::SetWindowText( hwnd, tmp );
GetDlgItem( IDC_VRAM_SPEED, &hwnd );
::SetWindowText( hwnd, tmp );
GetDlgItem( IDC_3D_GRAPHICS_ACCELERATOR, &hwnd );
::SetWindowText( hwnd, tmp );
sprintf(tmp, "%s", tmp_str.GetBuffer(0));
GetDlgItem(IDC_CPU_TYPE, &hwnd);
::SetWindowText(hwnd, tmp);
GetDlgItem(IDC_CPU_SPEED, &hwnd);
::SetWindowText(hwnd, tmp);
GetDlgItem(IDC_TOTAL_RAM, &hwnd);
::SetWindowText(hwnd, tmp);
GetDlgItem(IDC_RAM_SPEED, &hwnd);
::SetWindowText(hwnd, tmp);
GetDlgItem(IDC_VRAM_SPEED, &hwnd);
::SetWindowText(hwnd, tmp);
GetDlgItem(IDC_3D_GRAPHICS_ACCELERATOR, &hwnd);
::SetWindowText(hwnd, tmp);
int cpu, mmx, timestamp_available;
detect_cpu( &cpu, &mmx, &timestamp_available );
detect_cpu(&cpu, &mmx, &timestamp_available);
switch( cpu ) {
switch (cpu) {
case 3:
sprintf( tmp, "i386" );
sprintf(tmp, "i386");
break;
case 4:
sprintf( tmp, "i486" );
sprintf(tmp, "i486");
break;
case 5:
sprintf( tmp, "Pentium " );
if ( mmx ) {
strcat( tmp, " w/ MMX" );
sprintf(tmp, "Pentium ");
if (mmx) {
strcat(tmp, " w/ MMX");
}
break;
case 6:
if (SupportsKatmai()) {
sprintf( tmp, "Pentium III" );
} else if ( mmx ) {
sprintf( tmp, "Pentium II w/ MMX" );
sprintf(tmp, "Pentium III");
} else if (mmx) {
sprintf(tmp, "Pentium II w/ MMX");
} else {
sprintf( tmp, "Pentium Pro" );
sprintf(tmp, "Pentium Pro");
}
break;
default:
sprintf( tmp, "i%d86, MMX:%s", cpu, (mmx?"Yes":"No") );
sprintf(tmp, "i%d86, MMX:%s", cpu, (mmx ? "Yes" : "No"));
break;
}
GetDlgItem( IDC_CPU_TYPE, &hwnd );
::SetWindowText( hwnd, tmp );
GetDlgItem(IDC_CPU_TYPE, &hwnd);
::SetWindowText(hwnd, tmp);
int NiceMhz = 0;
if ( timestamp_available ) {
if (timestamp_available) {
DWORD t1;
DWORD c1, c2;
@@ -425,59 +409,55 @@ void CSpeedTab::OnBtnSpeedDetect()
c1 = ReadClocks();
while( timeGetTime() < t1 ) {
while (timeGetTime() < t1) {
}
c2 = ReadClocks();
} while ( c2 < c1 ); // Retry if it rolled
} while (c2 < c1); // Retry if it rolled
int Mhz = c2-c1;
int Mhz = c2 - c1;
// Round to the nearest multiple of 16.66666666666667
int factor = (Mhz+(16666667/2)) / 16666667;
int factor = (Mhz + (16666667 / 2)) / 16666667;
NiceMhz = (factor*16666667);
NiceMhz = (factor * 16666667);
NiceMhz /= 1000000;
}
if ( NiceMhz < 1 ) {
sprintf( tmp, "Unknown\n" );
if (NiceMhz < 1) {
sprintf(tmp, "Unknown\n");
} else {
sprintf( tmp, "%d MHz\n", NiceMhz );
sprintf(tmp, "%d MHz\n", NiceMhz);
}
GetDlgItem( IDC_CPU_SPEED, &hwnd );
::SetWindowText( hwnd, tmp );
GetDlgItem(IDC_CPU_SPEED, &hwnd);
::SetWindowText(hwnd, tmp);
MEMORYSTATUS ms;
ms.dwLength = sizeof(MEMORYSTATUS);
GlobalMemoryStatus(&ms);
DWORD descent3_total_ram = (ms.dwTotalPhys+(4194304/2))/(4194304);
DWORD descent3_total_ram = (ms.dwTotalPhys + (4194304 / 2)) / (4194304);
descent3_total_ram *= 4;
sprintf( tmp, "%d MB", descent3_total_ram );
GetDlgItem( IDC_TOTAL_RAM, &hwnd );
::SetWindowText( hwnd, tmp );
sprintf(tmp, "%d MB", descent3_total_ram);
GetDlgItem(IDC_TOTAL_RAM, &hwnd);
::SetWindowText(hwnd, tmp);
// Test memory READ speed.
int *array1, *array2;
array1 = new int[1024*1024];
array2 = new int[1024*1024];
array1 = new int[1024 * 1024];
array2 = new int[1024 * 1024];
int64_t ct1, ct2, freq;
QueryPerformanceCounter( (LARGE_INTEGER *)&ct1 );
QueryPerformanceCounter((LARGE_INTEGER *)&ct1);
int count=0;
int count = 0;
DWORD t1 = timeGetTime() + 1000;
while( timeGetTime() < t1 ) {
while (timeGetTime() < t1) {
_asm {
push esi
push edi
@@ -493,93 +473,90 @@ void CSpeedTab::OnBtnSpeedDetect()
count++;
}
QueryPerformanceCounter( (LARGE_INTEGER *)&ct2 );
QueryPerformanceFrequency( (LARGE_INTEGER *)&freq );
QueryPerformanceCounter((LARGE_INTEGER *)&ct2);
QueryPerformanceFrequency((LARGE_INTEGER *)&freq);
delete(array1);
delete(array2);
delete (array1);
delete (array2);
int64_t deltat = (ct2-ct1)/count;
int64_t deltat = (ct2 - ct1) / count;
int speed = int(freq/deltat);
int speed = int(freq / deltat);
// Round to nearest 10 MB/s
// speed = (speed+5)/10;
// speed = speed*10;
sprintf( tmp, "%d MB/s", speed );
GetDlgItem( IDC_RAM_SPEED, &hwnd );
::SetWindowText( hwnd, tmp );
// speed = (speed+5)/10;
// speed = speed*10;
sprintf(tmp, "%d MB/s", speed);
GetDlgItem(IDC_RAM_SPEED, &hwnd);
::SetWindowText(hwnd, tmp);
HDC hScreenDC = ::GetDC(NULL);
HDC hMemDC = CreateCompatibleDC(hScreenDC);
int w, h;
w = GetDeviceCaps(hScreenDC,HORZRES);
h = GetDeviceCaps(hScreenDC,VERTRES);
w = GetDeviceCaps(hScreenDC, HORZRES);
h = GetDeviceCaps(hScreenDC, VERTRES);
HBITMAP hBmp = CreateCompatibleBitmap( hScreenDC, w, h*4 );
if (hBmp && hScreenDC && hMemDC ) {
SelectObject( hMemDC, hBmp );
HBITMAP hBmp = CreateCompatibleBitmap(hScreenDC, w, h * 4);
if (hBmp && hScreenDC && hMemDC) {
SelectObject(hMemDC, hBmp);
BitBlt( hMemDC, 0, 0, w, h, hScreenDC, 0, 0, SRCCOPY );
BitBlt(hMemDC, 0, 0, w, h, hScreenDC, 0, 0, SRCCOPY);
QueryPerformanceCounter( (LARGE_INTEGER *)&ct1 );
BitBlt( hScreenDC, 0, 0, w, h, hMemDC, 0, 0, SRCCOPY );
QueryPerformanceCounter((LARGE_INTEGER *)&ct1);
BitBlt(hScreenDC, 0, 0, w, h, hMemDC, 0, 0, SRCCOPY);
GdiFlush();
QueryPerformanceCounter( (LARGE_INTEGER *)&ct2 );
QueryPerformanceCounter((LARGE_INTEGER *)&ct2);
QueryPerformanceFrequency( (LARGE_INTEGER *)&freq );
QueryPerformanceFrequency((LARGE_INTEGER *)&freq);
deltat = ct2-ct1;
deltat = ct2 - ct1;
//int64_t speed = (int64_t(300)*freq)/(deltat*int64_t(1024));
// int64_t speed = (int64_t(300)*freq)/(deltat*int64_t(1024));
int bpp = GetDeviceCaps(hScreenDC,BITSPIXEL);
int bpp1 = (bpp+7)/8;
int bpp = GetDeviceCaps(hScreenDC, BITSPIXEL);
int bpp1 = (bpp + 7) / 8;
int64_t vram_speed = freq;
vram_speed /= (int64_t)deltat;
vram_speed *= (int64_t)(w*h*bpp1);
vram_speed /= (int64_t)(1024*1024);
vram_speed *= (int64_t)(w * h * bpp1);
vram_speed /= (int64_t)(1024 * 1024);
speed = int(vram_speed);
sprintf( tmp, "%d MB/s\n", speed );
GetDlgItem( IDC_VRAM_SPEED, &hwnd );
::SetWindowText( hwnd, tmp );
sprintf(tmp, "%d MB/s\n", speed);
GetDlgItem(IDC_VRAM_SPEED, &hwnd);
::SetWindowText(hwnd, tmp);
DeleteObject(hBmp);
} else {
speed = 0;
sprintf( tmp, "%d MB/s\n", speed );
GetDlgItem( IDC_VRAM_SPEED, &hwnd );
::SetWindowText( hwnd, "unknown" );
sprintf(tmp, "%d MB/s\n", speed);
GetDlgItem(IDC_VRAM_SPEED, &hwnd);
::SetWindowText(hwnd, "unknown");
}
::DeleteDC( hMemDC );
::DeleteDC( hScreenDC );
::DeleteDC(hMemDC);
::DeleteDC(hScreenDC);
int current_card = 0;
int graphics_accelerator = RENDERER_NONE;
GetDlgItem( IDC_3D_GRAPHICS_ACCELERATOR, &hwnd );
GetDlgItem(IDC_3D_GRAPHICS_ACCELERATOR, &hwnd);
// If the video tab has been initialized, get card from there
if ( CurrentVideoTab && Num_cards !=0 ) {
if (CurrentVideoTab && Num_cards != 0) {
current_card = CurrentVideoTab->GetCurrentCard();
::SetWindowText( hwnd, GetFullName(&Cards[current_card]) );
graphics_accelerator=Cards[current_card].renderer_type;
}
else { // otherwise, get it from the registry
::SetWindowText(hwnd, GetFullName(&Cards[current_card]));
graphics_accelerator = Cards[current_card].renderer_type;
} else { // otherwise, get it from the registry
RendererType renderer_id = (RendererType)os_config_read_uint(NULL, "PreferredRenderer", RENDERER_NONE);
char *card_name = os_config_read_string(szSectionName, "RenderingDeviceName", "" );
char *card_name = os_config_read_string(szSectionName, "RenderingDeviceName", "");
card3d temp_card;
temp_card.renderer_type=renderer_id;
strcpy(temp_card.name,card_name);
::SetWindowText( hwnd, GetFullName(&temp_card) );
graphics_accelerator=temp_card.renderer_type;
temp_card.renderer_type = renderer_id;
strcpy(temp_card.name, card_name);
::SetWindowText(hwnd, GetFullName(&temp_card));
graphics_accelerator = temp_card.renderer_type;
}
// Calculate default detail level based on CPU speed, and then weight it on
@@ -587,45 +564,44 @@ void CSpeedTab::OnBtnSpeedDetect()
int recommended_detail_level;
// calculate setting based roughly on CPU speed
if ( NiceMhz <= 300 ) {
if (NiceMhz <= 300) {
recommended_detail_level = LOW_DETAIL;
} else if ( NiceMhz <= 400 ) {
} else if (NiceMhz <= 400) {
recommended_detail_level = MEDIUM_DETAIL;
} else if ( NiceMhz <= 500 ) {
} else if (NiceMhz <= 500) {
recommended_detail_level = HIGH_DETAIL;
} else {
recommended_detail_level = VERY_HIGH_DETAIL;
}
// weight the setting if user has ample supply of RAM
if ( descent3_total_ram >= 64 )
if (descent3_total_ram >= 64)
recommended_detail_level++;
// weight the setting if user has Glide selected as API
if ( graphics_accelerator == RENDERER_GLIDE )
if (graphics_accelerator == RENDERER_GLIDE)
recommended_detail_level++;
// Make sure detail level is capped at the highest setting
if ( recommended_detail_level > VERY_HIGH_DETAIL )
if (recommended_detail_level > VERY_HIGH_DETAIL)
recommended_detail_level = VERY_HIGH_DETAIL;
// Ask the user if he/she wants detail level changed
if(m_speed_list.GetCurSel()!=recommended_detail_level) {
if (m_speed_list.GetCurSel() != recommended_detail_level) {
CString speed_prompt, speed_title;
speed_prompt.LoadString(IDS_SPEEDTAB_SPEED_PROMPT);
speed_title.LoadString(IDS_SPEEDTAB_SPEED_TITLE);
if(MessageBox(speed_prompt,speed_title,MB_YESNO|MB_ICONQUESTION)==IDNO)
if (MessageBox(speed_prompt, speed_title, MB_YESNO | MB_ICONQUESTION) == IDNO)
return;
}
// Set the new detail level
m_speed_list.SetCurSel(recommended_detail_level);
DetailLevelConfigured=TRUE;
m_WriteDetailValues=TRUE;
DetailLevelConfigured = TRUE;
m_WriteDetailValues = TRUE;
}
BOOL CSpeedTab::OnHelpInfo(HELPINFO* pHelpInfo)
{
BOOL CSpeedTab::OnHelpInfo(HELPINFO *pHelpInfo) {
// TODO: Add your message handler code here and/or call default
#ifdef USE_HTML_HELP_SYSTEM
@@ -638,19 +614,16 @@ BOOL CSpeedTab::OnHelpInfo(HELPINFO* pHelpInfo)
}
// Display the html help file
afx_msg LRESULT CSpeedTab::OnCommandHelp(WPARAM wParam, LPARAM lParam)
{
afx_msg LRESULT CSpeedTab::OnCommandHelp(WPARAM wParam, LPARAM lParam) {
#ifdef USE_HTML_HELP_SYSTEM
help_launch(SPEEDTAB_HELP);
return 1;
#else
return CPropertyPage::OnCommandHelp(wParam,lParam);
return CPropertyPage::OnCommandHelp(wParam, lParam);
#endif
}
void CSpeedTab::OnSelchangeSpeedList()
{
void CSpeedTab::OnSelchangeSpeedList() {
// TODO: Add your control notification handler code here
m_WriteDetailValues=TRUE;
m_WriteDetailValues = TRUE;
}

View File

@@ -64,45 +64,43 @@
#define VERY_HIGH_DETAIL 3
#define CUSTOM_DETAIL 4
class CSpeedTab : public CPropertyPage
{
class CSpeedTab : public CPropertyPage {
DECLARE_DYNCREATE(CSpeedTab)
// Construction
// Construction
public:
CSpeedTab();
~CSpeedTab();
bool m_WriteDetailValues;
// Dialog Data
// Dialog Data
//{{AFX_DATA(CSpeedTab)
enum { IDD = IDD_PROPPAGE_SPEED };
CComboBox m_speed_list;
//}}AFX_DATA
// Overrides
// Overrides
// ClassWizard generate virtual function overrides
//{{AFX_VIRTUAL(CSpeedTab)
public:
public:
virtual void OnOK();
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
protected:
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CSpeedTab)
virtual BOOL OnInitDialog();
afx_msg void OnBtnSpeedDetect();
afx_msg LRESULT OnCommandHelp(WPARAM wParam, LPARAM lParam);
afx_msg BOOL OnHelpInfo(HELPINFO* pHelpInfo);
afx_msg BOOL OnHelpInfo(HELPINFO *pHelpInfo);
afx_msg void OnSelchangeSpeedList();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}

View File

@@ -1,24 +1,23 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// stdafx.cpp : source file that includes just the standard includes
// D3Launch.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
@@ -32,12 +32,11 @@
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
//#include <afxdisp.h> // MFC OLE automation classes
// #include <afxdisp.h> // MFC OLE automation classes
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
////////////////////////////////////////////////////////////////////////////
// TitleTip.cpp : implementation file
@@ -32,8 +32,7 @@ static char THIS_FILE[] = __FILE__;
/////////////////////////////////////////////////////////////////////////////
// CTitleTip
CTitleTip::CTitleTip()
{
CTitleTip::CTitleTip() {
m_iHorzSpace = 2;
m_brshBackground = (HBRUSH)0;
@@ -43,25 +42,20 @@ CTitleTip::CTitleTip()
RegisterWindowClass(); // Register window class if not already registered.
}
CTitleTip::~CTitleTip()
{
}
CTitleTip::~CTitleTip() {}
// static
void
CTitleTip::RegisterWindowClass()
{
void CTitleTip::RegisterWindowClass() {
WNDCLASS wndcls;
HINSTANCE hInst = AfxGetInstanceHandle();
if(!(::GetClassInfo(hInst, TITLETIP_CLASSNAME, &wndcls)))
{
if (!(::GetClassInfo(hInst, TITLETIP_CLASSNAME, &wndcls))) {
// otherwise we need to register a new class
wndcls.style = CS_SAVEBITS | CS_DBLCLKS;
wndcls.lpfnWndProc = ::DefWindowProc;
wndcls.cbClsExtra = wndcls.cbWndExtra = 0;
wndcls.hInstance = hInst;
wndcls.hIcon = NULL;
wndcls.hCursor = LoadCursor( hInst, IDC_ARROW );
wndcls.hCursor = LoadCursor(hInst, IDC_ARROW);
wndcls.hbrBackground = (HBRUSH)(COLOR_INFOBK + 1);
wndcls.lpszMenuName = NULL;
wndcls.lpszClassName = TITLETIP_CLASSNAME;
@@ -70,72 +64,59 @@ CTitleTip::RegisterWindowClass()
}
}
BEGIN_MESSAGE_MAP(CTitleTip, CWnd)
//{{AFX_MSG_MAP(CTitleTip)
ON_WM_MOUSEMOVE()
//}}AFX_MSG_MAP
//{{AFX_MSG_MAP(CTitleTip)
ON_WM_MOUSEMOVE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CTitleTip::SetBackground(HBRUSH brshBackground)
{
m_brshBackground = brshBackground;
}
void CTitleTip::SetBackground(HBRUSH brshBackground) { m_brshBackground = brshBackground; }
void CTitleTip::SetBkColor(COLORREF crColor)
{
m_clrBackground = crColor;
}
void CTitleTip::SetBkColor(COLORREF crColor) { m_clrBackground = crColor; }
void CTitleTip::SetTextColor(COLORREF crColor)
{
m_clrText = crColor;
}
void CTitleTip::SetTextColor(COLORREF crColor) { m_clrText = crColor; }
/////////////////////////////////////////////////////////////////////////////
// CTitleTip message handlers
/*
* styles:
* <UL>
* <LI>WS_BORDER: draws a border around the titletip window
* <LI>WS_POPUP: needed so that the TitleTip window is able to extend
* beyond the boundary of the control
* <LI>WS_EX_TOOLWINDOW: stops the window from appearing in the task bar
* <LI>WS_EX_TOPMOST: ensures the titletip is visible
* <LI>COLOR_INFOBK: the same color used by ToolTip
* </UL>
*/
* styles:
* <UL>
* <LI>WS_BORDER: draws a border around the titletip window
* <LI>WS_POPUP: needed so that the TitleTip window is able to extend
* beyond the boundary of the control
* <LI>WS_EX_TOOLWINDOW: stops the window from appearing in the task bar
* <LI>WS_EX_TOPMOST: ensures the titletip is visible
* <LI>COLOR_INFOBK: the same color used by ToolTip
* </UL>
*/
BOOL CTitleTip::Create(CWnd * pParentWnd)
{
BOOL CTitleTip::Create(CWnd *pParentWnd) {
ASSERT_VALID(pParentWnd);
DWORD dwStyle = WS_BORDER | WS_POPUP;
DWORD dwExStyle = WS_EX_TOOLWINDOW | WS_EX_TOPMOST;
m_pParentWnd = pParentWnd;
return CreateEx( dwExStyle, TITLETIP_CLASSNAME, NULL, dwStyle, 0, 0, 0, 0,
NULL, NULL, NULL );
return CreateEx(dwExStyle, TITLETIP_CLASSNAME, NULL, dwStyle, 0, 0, 0, 0, NULL, NULL, NULL);
}
/**
* This gets called repeatedly by its parent control.
* Determines whether the text extent of pszTitleText is too big for the
* original rectangle (rectTitle) and displays a TitleTip if required.
*
* @memo Displays the titletip if required.
*
* @param rectTitle rectangle for the original title - in client coordinates
* @param sTitleText text to be displayed
* @param xoffset number of pixel the text is offset from left border of the cell
*/
* This gets called repeatedly by its parent control.
* Determines whether the text extent of pszTitleText is too big for the
* original rectangle (rectTitle) and displays a TitleTip if required.
*
* @memo Displays the titletip if required.
*
* @param rectTitle rectangle for the original title - in client coordinates
* @param sTitleText text to be displayed
* @param xoffset number of pixel the text is offset from left border of the cell
*/
void CTitleTip::Show(CRect rectTitle, CString sTitleText, int xoffset /*=0*/)
{
void CTitleTip::Show(CRect rectTitle, CString sTitleText, int xoffset /*=0*/) {
ASSERT(::IsWindow(m_hWnd));
ASSERT(!rectTitle.IsRectEmpty());
if(GetFocus() == NULL) // only display titletip if app has focus
if (GetFocus() == NULL) // only display titletip if app has focus
return;
// Define the rectangle outside which the titletip will be hidden.
@@ -154,28 +135,23 @@ void CTitleTip::Show(CRect rectTitle, CString sTitleText, int xoffset /*=0*/)
CSize size = dc.GetTextExtent(sTitleText);
CRect rectDisplay = rectTitle;
rectDisplay.left += xoffset - GetHorzSpace();
rectDisplay.right = rectDisplay.left + size.cx + 2 + 2*GetHorzSpace();
rectDisplay.right = rectDisplay.left + size.cx + 2 + 2 * GetHorzSpace();
// Do not display if the text fits within available space
if(size.cx <= rectTitle.Width()-2*xoffset-2)
if (size.cx <= rectTitle.Width() - 2 * xoffset - 2)
return;
// Show the titletip
SetWindowPos(&wndTop, rectDisplay.left, rectDisplay.top,
rectDisplay.Width(), rectDisplay.Height(),
SWP_SHOWWINDOW|SWP_NOACTIVATE);
SetWindowPos(&wndTop, rectDisplay.left, rectDisplay.top, rectDisplay.Width(), rectDisplay.Height(),
SWP_SHOWWINDOW | SWP_NOACTIVATE);
if(m_brshBackground)
{
if (m_brshBackground) {
dc.SetTextColor(m_clrText);
dc.SetBkColor(m_clrBackground);
dc.SetBkMode(OPAQUE);
dc.SelectObject(CBrush::FromHandle(m_brshBackground));
dc.FillSolidRect(0, 0, rectDisplay.Width(), rectDisplay.Height(), m_clrBackground);
}
else
{
} else {
dc.SetBkMode(TRANSPARENT);
}
@@ -187,40 +163,33 @@ void CTitleTip::Show(CRect rectTitle, CString sTitleText, int xoffset /*=0*/)
}
/*
* Hide if the mouse is outside the original rectangle. Note that this is
* smaller than the actual window rectangle.
*/
void CTitleTip::OnMouseMove(UINT nFlags, CPoint point)
{
if(!m_rectTitle.PtInRect(point))
{
* Hide if the mouse is outside the original rectangle. Note that this is
* smaller than the actual window rectangle.
*/
void CTitleTip::OnMouseMove(UINT nFlags, CPoint point) {
if (!m_rectTitle.PtInRect(point)) {
ReleaseCapture();
ShowWindow(SW_HIDE);
// Forward the message
ClientToScreen(&point);
CWnd *pWnd = WindowFromPoint(point);
if(pWnd == this)
if (pWnd == this)
pWnd = m_pParentWnd;
int hittest = (int)pWnd->SendMessage(WM_NCHITTEST,0,MAKELONG(point.x,point.y));
if(hittest == HTCLIENT)
{
int hittest = (int)pWnd->SendMessage(WM_NCHITTEST, 0, MAKELONG(point.x, point.y));
if (hittest == HTCLIENT) {
pWnd->ScreenToClient(&point);
pWnd->PostMessage(WM_MOUSEMOVE, nFlags, MAKELONG(point.x,point.y));
}
else
{
pWnd->PostMessage( WM_NCMOUSEMOVE, hittest, MAKELONG(point.x,point.y));
pWnd->PostMessage(WM_MOUSEMOVE, nFlags, MAKELONG(point.x, point.y));
} else {
pWnd->PostMessage(WM_NCMOUSEMOVE, hittest, MAKELONG(point.x, point.y));
}
}
}
BOOL CTitleTip::PreTranslateMessage(MSG* pMsg)
{
BOOL CTitleTip::PreTranslateMessage(MSG *pMsg) {
CWnd *pWnd;
int hittest ;
switch(pMsg->message)
{
int hittest;
switch (pMsg->message) {
case WM_LBUTTONDBLCLK:
case WM_RBUTTONDBLCLK:
case WM_MBUTTONDBLCLK:
@@ -236,19 +205,15 @@ BOOL CTitleTip::PreTranslateMessage(MSG* pMsg)
point.y = pts.y;
ClientToScreen(&point);
pWnd = WindowFromPoint(point);
if(pWnd == this)
if (pWnd == this)
pWnd = m_pParentWnd;
hittest = (int)pWnd->SendMessage(WM_NCHITTEST,0,MAKELONG(point.x,point.y));
if(hittest == HTCLIENT)
{
hittest = (int)pWnd->SendMessage(WM_NCHITTEST, 0, MAKELONG(point.x, point.y));
if (hittest == HTCLIENT) {
pWnd->ScreenToClient(&point);
pMsg->lParam = MAKELONG(point.x,point.y);
}
else
{
switch(pMsg->message)
{
pMsg->lParam = MAKELONG(point.x, point.y);
} else {
switch (pMsg->message) {
case WM_LBUTTONDOWN:
pMsg->message = WM_NCLBUTTONDOWN;
break;
@@ -260,11 +225,11 @@ BOOL CTitleTip::PreTranslateMessage(MSG* pMsg)
break;
}
pMsg->wParam = hittest;
pMsg->lParam = MAKELONG(point.x,point.y);
pMsg->lParam = MAKELONG(point.x, point.y);
ShowWindow(SW_HIDE);
}
pWnd->SendMessage(pMsg->message,pMsg->wParam,pMsg->lParam);
if(GetCapture() == NULL)
pWnd->SendMessage(pMsg->message, pMsg->wParam, pMsg->lParam);
if (GetCapture() == NULL)
SetCapture();
return TRUE;
case WM_KEYDOWN:
@@ -275,8 +240,7 @@ BOOL CTitleTip::PreTranslateMessage(MSG* pMsg)
return TRUE;
}
if(GetFocus() == NULL)
{
if (GetFocus() == NULL) {
ReleaseCapture();
ShowWindow(SW_HIDE);
return TRUE;

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#if !defined(AFX_TITLETIP_H__FB05F243_E98F_11D0_82A3_20933B000000__INCLUDED_)
#define AFX_TITLETIP_H__FB05F243_E98F_11D0_82A3_20933B000000__INCLUDED_
@@ -31,13 +31,12 @@
#define TITLETIP_CLASSNAME _T("ZTitleTip")
/**
* Titletips similar to tooltips. For ListView controls, TitleTips are used to
* display text of those cells which are not wide enough to display the text
* completely. TitleTips show up as soon as the mouse moves over the cell.
*/
* Titletips similar to tooltips. For ListView controls, TitleTips are used to
* display text of those cells which are not wide enough to display the text
* completely. TitleTips show up as soon as the mouse moves over the cell.
*/
class CTitleTip : public CWnd
{
class CTitleTip : public CWnd {
// Construction
public:
CTitleTip();
@@ -45,21 +44,19 @@ public:
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CTitleTip)
public:
virtual BOOL PreTranslateMessage(MSG* pMsg);
virtual BOOL Create(CWnd* pParentWnd);
virtual BOOL PreTranslateMessage(MSG *pMsg);
virtual BOOL Create(CWnd *pParentWnd);
//}}AFX_VIRTUAL
// Implementation
public:
int GetHorzSpace() {return m_iHorzSpace;}
int GetHorzSpace() { return m_iHorzSpace; }
void SetBackground(HBRUSH brshBackground);
void SetBkColor(COLORREF crColor);
void SetTextColor(COLORREF crColor);
@@ -68,7 +65,7 @@ public:
static void RegisterWindowClass();
protected:
CWnd* m_pParentWnd;
CWnd *m_pParentWnd;
CRect m_rectTitle;
HBRUSH m_brshBackground;
COLORREF m_clrBackground;

File diff suppressed because it is too large Load Diff

View File

@@ -90,15 +90,14 @@
#define GETHTTPFILE_HOST_NOT_FOUND 7
#define GETHTTPFILE_NO_MEMORY 8
class CUpdateDlg : public CDialog
{
// Construction
class CUpdateDlg : public CDialog {
// Construction
public:
int m_should_verify; // should actually go through the verification process
void StatusBar(UINT strID);
void StatusBar(char *status);
void LocalizedMessageBox(UINT msgID, UINT titleID, UINT type=MB_OK);
void LocalizedMessageBox(UINT msgID, UINT titleID, UINT type = MB_OK);
void AddToList(UINT strID);
void CloseHTTP();
BOOL InitHTTP();
@@ -109,15 +108,15 @@ public:
int UpdateTheLauncher();
void GetHTTPFileErrorBox(int error_id, char *remote, char *local);
BOOL ParseMOTDFile(void);
void DisplayVersions(int maj1, int min1, int bld1, int maj2=-1, int min2=-1, int bld2=-1);
void DisplayVersions(int maj1, int min1, int bld1, int maj2 = -1, int min2 = -1, int bld2 = -1);
void Cleanup(void);
CUpdateDlg(CWnd* pParent = NULL, int should_verify = 1); // standard constructor
CUpdateDlg(CWnd *pParent = NULL, int should_verify = 1); // standard constructor
CFont m_listfont; // font for the update feedback list
CMessageWindowDlg msg_dlg;
// Dialog Data
// Dialog Data
//{{AFX_DATA(CUpdateDlg)
enum { IDD = IDD_UPDATE_DIALOG };
CLabel m_UserMsgStatic;
@@ -130,15 +129,14 @@ public:
CString m_usermsg;
//}}AFX_DATA
// Overrides
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CUpdateDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
protected:
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
// Implementation
protected:
BOOL GetVersionNfo();
BOOL GetMOTD();
@@ -156,7 +154,7 @@ protected:
virtual BOOL OnInitDialog();
afx_msg void OnClose();
afx_msg LRESULT OnCommandHelp(WPARAM wParam, LPARAM lParam);
afx_msg BOOL OnHelpInfo(HELPINFO* pHelpInfo);
afx_msg BOOL OnHelpInfo(HELPINFO *pHelpInfo);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// VideoDetectDlg.cpp : implementation file
//
@@ -34,26 +34,20 @@ static char THIS_FILE[] = __FILE__;
#define DETECT_OPENGL 0x02
#define DETECT_GLIDE 0x04
/////////////////////////////////////////////////////////////////////////////
// CVideoDetectDlg dialog
CVideoDetectDlg::CVideoDetectDlg(CWnd* pParent /*=NULL*/)
: CDialog(CVideoDetectDlg::IDD, pParent)
{
CVideoDetectDlg::CVideoDetectDlg(CWnd *pParent /*=NULL*/) : CDialog(CVideoDetectDlg::IDD, pParent) {
//{{AFX_DATA_INIT(CVideoDetectDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
DetectDirect3D=TRUE;
DetectOpenGL=TRUE;
DetectGlide=TRUE;
DetectDirect3D = TRUE;
DetectOpenGL = TRUE;
DetectGlide = TRUE;
}
void CVideoDetectDlg::DoDataExchange(CDataExchange* pDX)
{
void CVideoDetectDlg::DoDataExchange(CDataExchange *pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CVideoDetectDlg)
DDX_Control(pDX, IDC_OPENGL_CHECK, m_OpenGLCheck);
@@ -62,46 +56,46 @@ void CVideoDetectDlg::DoDataExchange(CDataExchange* pDX)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CVideoDetectDlg, CDialog)
//{{AFX_MSG_MAP(CVideoDetectDlg)
//}}AFX_MSG_MAP
//{{AFX_MSG_MAP(CVideoDetectDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CVideoDetectDlg message handlers
void CVideoDetectDlg::OnOK()
{
void CVideoDetectDlg::OnOK() {
// TODO: Add extra validation here
DetectDirect3D=m_Direct3DCheck.GetCheck();
DetectOpenGL=m_OpenGLCheck.GetCheck();
DetectGlide=m_GlideCheck.GetCheck();
DetectDirect3D = m_Direct3DCheck.GetCheck();
DetectOpenGL = m_OpenGLCheck.GetCheck();
DetectGlide = m_GlideCheck.GetCheck();
// Store these settings for next time
int settings=0;
if(DetectDirect3D) settings |= DETECT_DIRECT3D;
if(DetectOpenGL) settings |= DETECT_OPENGL;
if(DetectGlide) settings |= DETECT_GLIDE;
int settings = 0;
if (DetectDirect3D)
settings |= DETECT_DIRECT3D;
if (DetectOpenGL)
settings |= DETECT_OPENGL;
if (DetectGlide)
settings |= DETECT_GLIDE;
os_config_write_uint(szSectionName, "VideoDetectSettings", settings);
RenderersDetected=TRUE;
RenderersDetected = TRUE;
CDialog::OnOK();
}
BOOL CVideoDetectDlg::OnInitDialog()
{
BOOL CVideoDetectDlg::OnInitDialog() {
CDialog::OnInitDialog();
// TODO: Add extra initialization here
int settings;
// Get the settings from last time user chose
settings=os_config_read_uint(szSectionName, "VideoDetectSettings", DETECT_DIRECT3D|DETECT_GLIDE);
DetectDirect3D=settings & DETECT_DIRECT3D;
DetectOpenGL=settings & DETECT_OPENGL;
DetectGlide=settings & DETECT_GLIDE;
settings = os_config_read_uint(szSectionName, "VideoDetectSettings", DETECT_DIRECT3D | DETECT_GLIDE);
DetectDirect3D = settings & DETECT_DIRECT3D;
DetectOpenGL = settings & DETECT_OPENGL;
DetectGlide = settings & DETECT_GLIDE;
// Set the check marks appropriately
m_Direct3DCheck.SetCheck(DetectDirect3D);

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#if !defined(AFX_VIDEODETECTDLG_H__11362FC3_61E3_11D2_A4E0_00A0C96ED60D__INCLUDED_)
#define AFX_VIDEODETECTDLG_H__11362FC3_61E3_11D2_A4E0_00A0C96ED60D__INCLUDED_
@@ -28,17 +28,16 @@
/////////////////////////////////////////////////////////////////////////////
// CVideoDetectDlg dialog
class CVideoDetectDlg : public CDialog
{
// Construction
class CVideoDetectDlg : public CDialog {
// Construction
public:
CVideoDetectDlg(CWnd* pParent = NULL); // standard constructor
CVideoDetectDlg(CWnd *pParent = NULL); // standard constructor
int DetectOpenGL;
int DetectDirect3D;
int DetectGlide;
// Dialog Data
// Dialog Data
//{{AFX_DATA(CVideoDetectDlg)
enum { IDD = IDD_VIDEODETECT_DLG };
CButton m_OpenGLCheck;
@@ -46,17 +45,15 @@ public:
CButton m_Direct3DCheck;
//}}AFX_DATA
// Overrides
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CVideoDetectDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
protected:
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CVideoDetectDlg)
virtual void OnOK();

View File

@@ -103,7 +103,7 @@
static char THIS_FILE[] = __FILE__;
#endif
CVideoTab * CurrentVideoTab = NULL;
CVideoTab *CurrentVideoTab = NULL;
BOOL VideoTabInitialized = FALSE;
/////////////////////////////////////////////////////////////////////////////
@@ -111,8 +111,7 @@ BOOL VideoTabInitialized = FALSE;
IMPLEMENT_DYNCREATE(CVideoTab, CPropertyPage)
CVideoTab::CVideoTab() : CPropertyPage(CVideoTab::IDD)
{
CVideoTab::CVideoTab() : CPropertyPage(CVideoTab::IDD) {
//{{AFX_DATA_INIT(CVideoTab)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
@@ -120,37 +119,31 @@ CVideoTab::CVideoTab() : CPropertyPage(CVideoTab::IDD)
CurrentVideoTab = NULL;
}
CVideoTab::~CVideoTab()
{
CurrentVideoTab = NULL;
}
CVideoTab::~CVideoTab() { CurrentVideoTab = NULL; }
int CVideoTab::GetCurrentCard()
{
int CVideoTab::GetCurrentCard() {
int current = m_videocard_list.GetCurSel();
if ( (current < 0) || (current>=Num_cards)) {
if ((current < 0) || (current >= Num_cards)) {
current = 0;
}
return current;
}
void CVideoTab::DoDataExchange(CDataExchange* pDX)
{
void CVideoTab::DoDataExchange(CDataExchange *pDX) {
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CVideoTab)
DDX_Control(pDX, IDC_VIDEOCARD_LIST, m_videocard_list);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CVideoTab, CPropertyPage)
//{{AFX_MSG_MAP(CVideoTab)
ON_BN_CLICKED(IDC_VIDEOCARD_DETECT, OnVideocardDetect)
ON_MESSAGE(WM_COMMANDHELP,OnCommandHelp)
ON_WM_HELPINFO()
ON_CBN_SELCHANGE(IDC_VIDEOCARD_LIST, OnSelchangeVideocardList)
//}}AFX_MSG_MAP
//{{AFX_MSG_MAP(CVideoTab)
ON_BN_CLICKED(IDC_VIDEOCARD_DETECT, OnVideocardDetect)
ON_MESSAGE(WM_COMMANDHELP, OnCommandHelp)
ON_WM_HELPINFO()
ON_CBN_SELCHANGE(IDC_VIDEOCARD_LIST, OnSelchangeVideocardList)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
@@ -158,10 +151,10 @@ END_MESSAGE_MAP()
extern HINSTANCE Dd_dll_handle;
void CVideoTab::OnVideocardDetect()
{
void CVideoTab::OnVideocardDetect() {
// TODO: Add your control notification handler code here
if(VideoCardsDetected) return;
if (VideoCardsDetected)
return;
#if (!defined(OEM_VOODOO3) || defined(USE_ALL_VIDEO_OPTIONS))
// Display the scan selection options to user
@@ -178,61 +171,60 @@ void CVideoTab::OnVideocardDetect()
// Display the scanning window
m_MsgDlg.m_ScanningMsg.LoadString(IDS_VIDEOTAB_SCANNING);
m_MsgDlg.m_WaitMsg.LoadString(IDS_PLEASE_WAIT_MSG);
m_MsgDlg.Create(IDD_MSG_DLG,this);
m_MsgDlg.Create(IDD_MSG_DLG, this);
m_MsgDlg.ShowWindow(SW_SHOW);
m_MsgDlg.UpdateData(FALSE);
#if (defined(OEM_VOODOO3) && !defined(USE_ALL_VIDEO_OPTIONS))
// Detect only 3dfx cards
detect_3dcards(0,1,0);
detect_3dcards(0, 1, 0);
#else
// Detect the cards
detect_3dcards(dlg.DetectDirect3D,dlg.DetectGlide,dlg.DetectOpenGL);
detect_3dcards(dlg.DetectDirect3D, dlg.DetectGlide, dlg.DetectOpenGL);
#endif
// Remove the scanning window
m_MsgDlg.DestroyWindow();
// Now that the window is gone, release the opengl dll (fixes crash)
if(opengl_dll_handle!=NULL) {
if (opengl_dll_handle != NULL) {
FreeLibrary(opengl_dll_handle);
opengl_dll_handle=NULL;
opengl_dll_handle = NULL;
}
int i;
int current=0;
int current = 0;
// Add cards to listbox
for (i=0; i<Num_cards; i++ ) {
for (i = 0; i < Num_cards; i++) {
// Construct the listbox name
m_videocard_list.InsertString( i, GetFullName(&Cards[i]) );
m_videocard_list.InsertString(i, GetFullName(&Cards[i]));
}
// If only one card (in addition to NONE option) has been detected, select it
if(Num_cards==2) current=1;
if (Num_cards == 2)
current = 1;
// If more than one card, then display the "you must select one" message
if(Num_cards>2) {
current=0; // set it to "none", make user pick
if (Num_cards > 2) {
current = 0; // set it to "none", make user pick
CString mtod_msg, mtod_title;
mtod_msg.LoadString(IDS_VIDEOTAB_MTOD_MSG);
mtod_title.LoadString(IDS_VIDEOTAB_MTOD_TITLE);
MessageBox(mtod_msg,mtod_title,MB_OK|MB_ICONINFORMATION);
MessageBox(mtod_msg, mtod_title, MB_OK | MB_ICONINFORMATION);
}
// Set the determined selection
m_videocard_list.SetCurSel(current);
// Desensitize detection button since cards have been detected
//HWND hwnd;
//GetDlgItem(IDC_VIDEOCARD_DETECT,&hwnd);
// HWND hwnd;
// GetDlgItem(IDC_VIDEOCARD_DETECT,&hwnd);
//::EnableWindow(hwnd,FALSE);
}
BOOL CVideoTab::OnInitDialog()
{
BOOL CVideoTab::OnInitDialog() {
CPropertyPage::OnInitDialog();
// TODO: Add extra initialization here
@@ -244,14 +236,14 @@ BOOL CVideoTab::OnInitDialog()
RendererType renderer_id = (RendererType)os_config_read_uint(NULL, "PreferredRenderer", RENDERER_NONE);
// Get the name of the selected rendering device
char *current_card = os_config_read_string(szSectionName, "RenderingDeviceName", "" );
char *current_card = os_config_read_string(szSectionName, "RenderingDeviceName", "");
// Clear the box
m_videocard_list.ResetContent();
// if renderer none is selected, automatically display the detection dialog
int current=-1;
if(renderer_id==RENDERER_NONE) {
int current = -1;
if (renderer_id == RENDERER_NONE) {
#if (!defined(OEM_VOODOO3) || defined(USE_ALL_VIDEO_OPTIONS))
// Display the scan selection options to user
@@ -265,57 +257,57 @@ BOOL CVideoTab::OnInitDialog()
// Display the scanning window
m_MsgDlg.m_ScanningMsg.LoadString(IDS_VIDEOTAB_SCANNING);
m_MsgDlg.m_WaitMsg.LoadString(IDS_PLEASE_WAIT_MSG);
m_MsgDlg.Create(IDD_MSG_DLG,this);
m_MsgDlg.Create(IDD_MSG_DLG, this);
m_MsgDlg.ShowWindow(SW_SHOW);
m_MsgDlg.UpdateData(FALSE);
#if (defined(OEM_VOODOO3) && !defined(USE_ALL_VIDEO_OPTIONS))
// Detect only 3dfx cards
detect_3dcards(0,1,0);
detect_3dcards(0, 1, 0);
#else
// Detect the cards
detect_3dcards(dlg.DetectDirect3D,dlg.DetectGlide,dlg.DetectOpenGL);
detect_3dcards(dlg.DetectDirect3D, dlg.DetectGlide, dlg.DetectOpenGL);
#endif
// Remove the scanning window
m_MsgDlg.DestroyWindow();
// Now that the window is gone, release the opengl dll (fixes crash)
if(opengl_dll_handle!=NULL) {
if (opengl_dll_handle != NULL) {
FreeLibrary(opengl_dll_handle);
opengl_dll_handle=NULL;
opengl_dll_handle = NULL;
}
// Put the detected cards into the list, and see if the selected card is one of them
for(int j=0; j<Num_cards; j++) {
m_videocard_list.InsertString( j, GetFullName(&Cards[j]) );
if ( Cards[j].renderer_type==renderer_id && !stricmp(Cards[j].name, current_card) )
current=j;
for (int j = 0; j < Num_cards; j++) {
m_videocard_list.InsertString(j, GetFullName(&Cards[j]));
if (Cards[j].renderer_type == renderer_id && !stricmp(Cards[j].name, current_card))
current = j;
}
}
else { // just put the selected card in the list (and none selected)
detect_3dcards(0,0,0);
m_videocard_list.InsertString( 0, GetFullName(&Cards[0]) );
Cards[Num_cards].renderer_type=renderer_id;
strcpy( Cards[Num_cards].name, current_card );
m_videocard_list.InsertString( Num_cards, GetFullName(&Cards[Num_cards]) );
} else { // just put the selected card in the list (and none selected)
detect_3dcards(0, 0, 0);
m_videocard_list.InsertString(0, GetFullName(&Cards[0]));
Cards[Num_cards].renderer_type = renderer_id;
strcpy(Cards[Num_cards].name, current_card);
m_videocard_list.InsertString(Num_cards, GetFullName(&Cards[Num_cards]));
current = Num_cards;
Num_cards++;
}
// Only do "auto-selection" when renderer_id is set to RENDERER_NONE
if(renderer_id==RENDERER_NONE || current==-1) {
if (renderer_id == RENDERER_NONE || current == -1) {
if(Num_cards<=2) current=Num_cards-1;
if (Num_cards <= 2)
current = Num_cards - 1;
// If more than one card, then display the "you must select one" message
if(Num_cards>2) {
current=0; // set it to "none", make user pick
if (Num_cards > 2) {
current = 0; // set it to "none", make user pick
CString mtod_msg, mtod_title;
mtod_msg.LoadString(IDS_VIDEOTAB_MTOD_MSG);
mtod_title.LoadString(IDS_VIDEOTAB_MTOD_TITLE);
MessageBox(mtod_msg,mtod_title,MB_OK|MB_ICONINFORMATION);
MessageBox(mtod_msg, mtod_title, MB_OK | MB_ICONINFORMATION);
}
}
@@ -331,8 +323,8 @@ BOOL CVideoTab::OnInitDialog()
*/
// Desensitize detection button since cards have been detected
//HWND hwnd;
//GetDlgItem(IDC_VIDEOCARD_DETECT,&hwnd);
// HWND hwnd;
// GetDlgItem(IDC_VIDEOCARD_DETECT,&hwnd);
//::EnableWindow(hwnd,FALSE);
/*
@@ -354,12 +346,11 @@ BOOL CVideoTab::OnInitDialog()
// EXCEPTION: OCX Property Pages should return FALSE
}
void CVideoTab::OnOK()
{
void CVideoTab::OnOK() {
// TODO: Add your specialized code here and/or call the base class
int current = m_videocard_list.GetCurSel();
if ( (current < 0) || (current>=Num_cards)) {
if ((current < 0) || (current >= Num_cards)) {
current = 0;
}
@@ -374,9 +365,7 @@ void CVideoTab::OnOK()
CPropertyPage::OnOK();
}
BOOL CVideoTab::OnHelpInfo(HELPINFO* pHelpInfo)
{
BOOL CVideoTab::OnHelpInfo(HELPINFO *pHelpInfo) {
// TODO: Add your message handler code here and/or call default
#ifdef USE_HTML_HELP_SYSTEM
@@ -389,32 +378,30 @@ BOOL CVideoTab::OnHelpInfo(HELPINFO* pHelpInfo)
}
// Display the html help file
afx_msg LRESULT CVideoTab::OnCommandHelp(WPARAM wParam, LPARAM lParam)
{
afx_msg LRESULT CVideoTab::OnCommandHelp(WPARAM wParam, LPARAM lParam) {
#ifdef USE_HTML_HELP_SYSTEM
help_launch(VIDEOTAB_HELP);
return 1;
#else
return CPropertyPage::OnCommandHelp(wParam,lParam);
return CPropertyPage::OnCommandHelp(wParam, lParam);
#endif
}
void CVideoTab::OnSelchangeVideocardList()
{
void CVideoTab::OnSelchangeVideocardList() {
int current = m_videocard_list.GetCurSel();
if ( (current < 0) || (current>=Num_cards)) {
if ((current < 0) || (current >= Num_cards)) {
current = 0;
}
// If user's DirectX version is less than 6.0,
// then don't let them select Direct 3D
if(Dx_version<6) {
if(Cards[current].renderer_type==RENDERER_DIRECT3D) {
if (Dx_version < 6) {
if (Cards[current].renderer_type == RENDERER_DIRECT3D) {
CString title, msg;
title.LoadString(IDS_VIDEOTAB_DXVERSION_TITLE);
msg.LoadString(IDS_VIDEOTAB_DXVERSION_MSG);
MessageBox(msg,title,MB_OK|MB_ICONEXCLAMATION);
MessageBox(msg, title, MB_OK | MB_ICONEXCLAMATION);
m_videocard_list.SetCurSel(0);
return;
}
@@ -422,20 +409,20 @@ void CVideoTab::OnSelchangeVideocardList()
// See if user has the option of selecting 3Dfx glide
int glide = -1;
for(int j=0;j<Num_cards;j++) {
if(Cards[j].renderer_type==RENDERER_GLIDE) {
glide=j;
for (int j = 0; j < Num_cards; j++) {
if (Cards[j].renderer_type == RENDERER_GLIDE) {
glide = j;
break;
}
}
// Display warning if user has glide and is choosing opengl or direct3d
if(glide>=0 && glide<Num_cards) {
if(Cards[current].renderer_type==RENDERER_DIRECT3D || Cards[current].renderer_type==RENDERER_OPENGL) {
if (glide >= 0 && glide < Num_cards) {
if (Cards[current].renderer_type == RENDERER_DIRECT3D || Cards[current].renderer_type == RENDERER_OPENGL) {
CString title, msg;
title.LoadString(IDS_NOTGLIDE_TITLE);
msg.LoadString(IDS_NOTGLIDE_MSG);
MessageBox(msg,title,MB_OK|MB_ICONEXCLAMATION);
MessageBox(msg, title, MB_OK | MB_ICONEXCLAMATION);
}
}
}

View File

@@ -71,11 +71,10 @@
/////////////////////////////////////////////////////////////////////////////
// CVideoTab dialog
class CVideoTab : public CPropertyPage
{
class CVideoTab : public CPropertyPage {
DECLARE_DYNCREATE(CVideoTab)
// Construction
// Construction
public:
CVideoTab();
~CVideoTab();
@@ -83,37 +82,36 @@ public:
int GetCurrentCard();
CMsgDlg m_MsgDlg;
// Dialog Data
// Dialog Data
//{{AFX_DATA(CVideoTab)
enum { IDD = IDD_PROPPAGE_VIDEO };
CComboBox m_videocard_list;
//}}AFX_DATA
// Overrides
// Overrides
// ClassWizard generate virtual function overrides
//{{AFX_VIRTUAL(CVideoTab)
public:
public:
virtual void OnOK();
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
protected:
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CVideoTab)
afx_msg void OnVideocardDetect();
virtual BOOL OnInitDialog();
afx_msg LRESULT OnCommandHelp(WPARAM wParam, LPARAM lParam);
afx_msg BOOL OnHelpInfo(HELPINFO* pHelpInfo);
afx_msg BOOL OnHelpInfo(HELPINFO *pHelpInfo);
afx_msg void OnSelchangeVideocardList();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
extern CVideoTab * CurrentVideoTab;
extern CVideoTab *CurrentVideoTab;
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.

View File

@@ -1,21 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// EAX.H -- DirectSound Environmental Audio Extensions
@@ -26,16 +25,11 @@
extern "C" {
#endif // __cplusplus
// EAX (listener) reverb property set {4a4e6fc1-c341-11d1-b73a-444553540000}
DEFINE_GUID(DSPROPSETID_EAX_ReverbProperties,
0x4a4e6fc1,
0xc341,
0x11d1,
0xb7, 0x3a, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00);
DEFINE_GUID(DSPROPSETID_EAX_ReverbProperties, 0x4a4e6fc1, 0xc341, 0x11d1, 0xb7, 0x3a, 0x44, 0x45, 0x53, 0x54, 0x00,
0x00);
enum DSPROPERTY_EAX_REVERBPROPERTY
{
enum DSPROPERTY_EAX_REVERBPROPERTY {
DSPROPERTY_EAX_ALL, // all reverb properties
DSPROPERTY_EAX_ENVIRONMENT, // standard environment no.
DSPROPERTY_EAX_VOLUME, // loudness of the reverb
@@ -46,66 +40,59 @@ enum DSPROPERTY_EAX_REVERBPROPERTY
#define EAX_NUM_STANDARD_PROPERTIES (DSPROPERTY_EAX_DAMPING + 1)
// use this structure for get/set all properties...
struct EAX_REVERBPROPERTIES
{
struct EAX_REVERBPROPERTIES {
uint32_t environment; // 0 to EAX_ENVIRONMENT_COUNT-1
float fVolume; // 0 to 1
float fDecayTime_sec; // seconds, 0.1 to 100
float fDamping; // 0 to 1
};
//#define EAX_MAX_ENVIRONMENT (EAX_ENVIRONMENT_COUNT - 1)
// #define EAX_MAX_ENVIRONMENT (EAX_ENVIRONMENT_COUNT - 1)
// presets
#define EAX_PRESET_GENERIC EAX_ENVIRONMENT_GENERIC,0.5F,1.493F,0.5F
#define EAX_PRESET_PADDEDCELL EAX_ENVIRONMENT_PADDEDCELL,0.25F,0.1F,0.0F
#define EAX_PRESET_ROOM EAX_ENVIRONMENT_ROOM,0.417F,0.4F,0.666F
#define EAX_PRESET_BATHROOM EAX_ENVIRONMENT_BATHROOM,0.653F,1.499F,0.166F
#define EAX_PRESET_LIVINGROOM EAX_ENVIRONMENT_LIVINGROOM,0.208F,0.478F,0.0F
#define EAX_PRESET_STONEROOM EAX_ENVIRONMENT_STONEROOM,0.5F,2.309F,0.888F
#define EAX_PRESET_AUDITORIUM EAX_ENVIRONMENT_AUDITORIUM,0.403F,4.279F,0.5F
#define EAX_PRESET_CONCERTHALL EAX_ENVIRONMENT_CONCERTHALL,0.5F,3.961F,0.5F
#define EAX_PRESET_CAVE EAX_ENVIRONMENT_CAVE,0.5F,2.886F,1.304F
#define EAX_PRESET_ARENA EAX_ENVIRONMENT_ARENA,0.361F,7.284F,0.332F
#define EAX_PRESET_HANGAR EAX_ENVIRONMENT_HANGAR,0.5F,10.0F,0.3F
#define EAX_PRESET_CARPETEDHALLWAY EAX_ENVIRONMENT_CARPETEDHALLWAY,0.153F,0.259F,2.0F
#define EAX_PRESET_HALLWAY EAX_ENVIRONMENT_HALLWAY,0.361F,1.493F,0.0F
#define EAX_PRESET_STONECORRIDOR EAX_ENVIRONMENT_STONECORRIDOR,0.444F,2.697F,0.638F
#define EAX_PRESET_ALLEY EAX_ENVIRONMENT_ALLEY,0.25F,1.752F,0.776F
#define EAX_PRESET_FOREST EAX_ENVIRONMENT_FOREST,0.111F,3.145F,0.472F
#define EAX_PRESET_CITY EAX_ENVIRONMENT_CITY,0.111F,2.767F,0.224F
#define EAX_PRESET_MOUNTAINS EAX_ENVIRONMENT_MOUNTAINS,0.194F,7.841F,0.472F
#define EAX_PRESET_QUARRY EAX_ENVIRONMENT_QUARRY,1.0F,1.499F,0.5F
#define EAX_PRESET_PLAIN EAX_ENVIRONMENT_PLAIN,0.097F,2.767F,0.224F
#define EAX_PRESET_PARKINGLOT EAX_ENVIRONMENT_PARKINGLOT,0.208F,1.652F,1.5F
#define EAX_PRESET_SEWERPIPE EAX_ENVIRONMENT_SEWERPIPE,0.652F,2.886F,0.25F
#define EAX_PRESET_UNDERWATER EAX_ENVIRONMENT_UNDERWATER,1.0F,1.499F,0.0F
#define EAX_PRESET_DRUGGED EAX_ENVIRONMENT_DRUGGED,0.875F,8.392F,1.388F
#define EAX_PRESET_DIZZY EAX_ENVIRONMENT_DIZZY,0.139F,17.234F,0.666F
#define EAX_PRESET_PSYCHOTIC EAX_ENVIRONMENT_PSYCHOTIC,0.486F,7.563F,0.806F
#define EAX_PRESET_GENERIC EAX_ENVIRONMENT_GENERIC, 0.5F, 1.493F, 0.5F
#define EAX_PRESET_PADDEDCELL EAX_ENVIRONMENT_PADDEDCELL, 0.25F, 0.1F, 0.0F
#define EAX_PRESET_ROOM EAX_ENVIRONMENT_ROOM, 0.417F, 0.4F, 0.666F
#define EAX_PRESET_BATHROOM EAX_ENVIRONMENT_BATHROOM, 0.653F, 1.499F, 0.166F
#define EAX_PRESET_LIVINGROOM EAX_ENVIRONMENT_LIVINGROOM, 0.208F, 0.478F, 0.0F
#define EAX_PRESET_STONEROOM EAX_ENVIRONMENT_STONEROOM, 0.5F, 2.309F, 0.888F
#define EAX_PRESET_AUDITORIUM EAX_ENVIRONMENT_AUDITORIUM, 0.403F, 4.279F, 0.5F
#define EAX_PRESET_CONCERTHALL EAX_ENVIRONMENT_CONCERTHALL, 0.5F, 3.961F, 0.5F
#define EAX_PRESET_CAVE EAX_ENVIRONMENT_CAVE, 0.5F, 2.886F, 1.304F
#define EAX_PRESET_ARENA EAX_ENVIRONMENT_ARENA, 0.361F, 7.284F, 0.332F
#define EAX_PRESET_HANGAR EAX_ENVIRONMENT_HANGAR, 0.5F, 10.0F, 0.3F
#define EAX_PRESET_CARPETEDHALLWAY EAX_ENVIRONMENT_CARPETEDHALLWAY, 0.153F, 0.259F, 2.0F
#define EAX_PRESET_HALLWAY EAX_ENVIRONMENT_HALLWAY, 0.361F, 1.493F, 0.0F
#define EAX_PRESET_STONECORRIDOR EAX_ENVIRONMENT_STONECORRIDOR, 0.444F, 2.697F, 0.638F
#define EAX_PRESET_ALLEY EAX_ENVIRONMENT_ALLEY, 0.25F, 1.752F, 0.776F
#define EAX_PRESET_FOREST EAX_ENVIRONMENT_FOREST, 0.111F, 3.145F, 0.472F
#define EAX_PRESET_CITY EAX_ENVIRONMENT_CITY, 0.111F, 2.767F, 0.224F
#define EAX_PRESET_MOUNTAINS EAX_ENVIRONMENT_MOUNTAINS, 0.194F, 7.841F, 0.472F
#define EAX_PRESET_QUARRY EAX_ENVIRONMENT_QUARRY, 1.0F, 1.499F, 0.5F
#define EAX_PRESET_PLAIN EAX_ENVIRONMENT_PLAIN, 0.097F, 2.767F, 0.224F
#define EAX_PRESET_PARKINGLOT EAX_ENVIRONMENT_PARKINGLOT, 0.208F, 1.652F, 1.5F
#define EAX_PRESET_SEWERPIPE EAX_ENVIRONMENT_SEWERPIPE, 0.652F, 2.886F, 0.25F
#define EAX_PRESET_UNDERWATER EAX_ENVIRONMENT_UNDERWATER, 1.0F, 1.499F, 0.0F
#define EAX_PRESET_DRUGGED EAX_ENVIRONMENT_DRUGGED, 0.875F, 8.392F, 1.388F
#define EAX_PRESET_DIZZY EAX_ENVIRONMENT_DIZZY, 0.139F, 17.234F, 0.666F
#define EAX_PRESET_PSYCHOTIC EAX_ENVIRONMENT_PSYCHOTIC, 0.486F, 7.563F, 0.806F
// EAX buffer reverb property set {4a4e6fc0-c341-11d1-b73a-444553540000}
DEFINE_GUID(DSPROPSETID_EAXBUFFER_ReverbProperties,
0x4a4e6fc0,
0xc341,
0x11d1,
0xb7, 0x3a, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00);
DEFINE_GUID(DSPROPSETID_EAXBUFFER_ReverbProperties, 0x4a4e6fc0, 0xc341, 0x11d1, 0xb7, 0x3a, 0x44, 0x45, 0x53, 0x54,
0x00, 0x00);
enum DSPROPERTY_EAXBUFFER_REVERBPROPERTY
{
enum DSPROPERTY_EAXBUFFER_REVERBPROPERTY {
DSPROPERTY_EAXBUFFER_ALL, // all reverb buffer properties
DSPROPERTY_EAXBUFFER_REVERBMIX // the wet source amount
};
// use this structure for get/set all properties...
struct EAXBUFFER_REVERBPROPERTIES
{
struct EAXBUFFER_REVERBPROPERTIES {
float fMix; // linear factor, 0.0F to 1.0F
};
#define EAX_REVERBMIX_USEDISTANCE -1.0F // out of normal range
#define EAX_REVERBMIX_USEDISTANCE \
-1.0F // out of normal range
// signifies the reverb engine should
// calculate it's own reverb mix value
// based on distance

File diff suppressed because it is too large Load Diff

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.

View File

@@ -40,8 +40,8 @@
extern char GameArgs[MAX_ARGS][MAX_CHARS_PER_ARG];
// Gathers all arguments
void GatherArgs (const char *str);
void GatherArgs(const char *str);
// Returns index of argument sought, or 0 if not found
int FindArg (const char *which);
int FindArg(const char *which);
#endif

View File

@@ -53,24 +53,17 @@
// Font File stuff
typedef FILE* FONTFILE;
typedef FILE *FONTFILE;
#define BITS_TO_BYTES(x) (((x)+7)>>3)
#define BITS_TO_BYTES(x) (((x) + 7) >> 3)
inline int WRITE_FONT_INT(FONTFILE ffile, int i) {
return fwrite(&i, sizeof(i), 1, (FILE *)ffile);
}
inline int WRITE_FONT_INT(FONTFILE ffile, int i) { return fwrite(&i, sizeof(i), 1, (FILE *)ffile); }
inline int WRITE_FONT_SHORT(FONTFILE ffile, int16_t s) {
return fwrite(&s, sizeof(s), 1, (FILE *)ffile);
}
inline int WRITE_FONT_SHORT(FONTFILE ffile, int16_t s) { return fwrite(&s, sizeof(s), 1, (FILE *)ffile); }
inline int WRITE_FONT_BYTE(FONTFILE ffile, uint8_t c) {
return fwrite(&c, sizeof(c), 1, (FILE *)ffile);
}
inline int WRITE_FONT_BYTE(FONTFILE ffile, uint8_t c) { return fwrite(&c, sizeof(c), 1, (FILE *)ffile); }
inline int WRITE_FONT_DATA(FONTFILE ffile, void *buf, int size, int nelem)
{
inline int WRITE_FONT_DATA(FONTFILE ffile, void *buf, int size, int nelem) {
int i;
i = (int)fwrite(buf, size, nelem, (FILE *)ffile);
@@ -83,18 +76,15 @@ inline FONTFILE OPEN_FONT(char *filename) {
FONTFILE fp;
fp = (FONTFILE)fopen(filename, "wb");
if (!fp) return NULL;
if (!fp)
return NULL;
return fp;
}
inline void CLOSE_FONT(FONTFILE ffile) {
fclose((FILE *)ffile);
}
inline void CLOSE_FONT(FONTFILE ffile) { fclose((FILE *)ffile); }
void message_box(const char *fmt, ...)
{
void message_box(const char *fmt, ...) {
#define FIXED_MSGBOX_WIDTH (512)
#define FIXED_MSGBOX_HEIGHT (128)
@@ -102,18 +92,18 @@ void message_box(const char *fmt, ...)
char buf[512];
int len;
va_start(arglist,fmt);
len = std::vsnprintf(buf,512,fmt,arglist);
va_start(arglist, fmt);
len = std::vsnprintf(buf, 512, fmt, arglist);
va_end(arglist);
if (len < 0) return;
if (len < 0)
return;
while(1)
{
while (1) {
int key;
int l = (FIXED_SCREEN_WIDTH-FIXED_MSGBOX_WIDTH)/2;
int t = (FIXED_SCREEN_HEIGHT-FIXED_MSGBOX_HEIGHT)/2;
int r = l+FIXED_MSGBOX_WIDTH;
int b = t+FIXED_MSGBOX_HEIGHT;
int l = (FIXED_SCREEN_WIDTH - FIXED_MSGBOX_WIDTH) / 2;
int t = (FIXED_SCREEN_HEIGHT - FIXED_MSGBOX_HEIGHT) / 2;
int r = l + FIXED_MSGBOX_WIDTH;
int b = t + FIXED_MSGBOX_HEIGHT;
FontDoIO();
key = ddio_KeyInKey();
@@ -121,35 +111,31 @@ void message_box(const char *fmt, ...)
break;
}
rend_StartFrame(0,0,FIXED_SCREEN_WIDTH,FIXED_SCREEN_HEIGHT,0);
grtext_SetParameters(0,0,FIXED_SCREEN_WIDTH,FIXED_SCREEN_HEIGHT);
rend_StartFrame(0, 0, FIXED_SCREEN_WIDTH, FIXED_SCREEN_HEIGHT, 0);
grtext_SetParameters(0, 0, FIXED_SCREEN_WIDTH, FIXED_SCREEN_HEIGHT);
grtext_SetFont(System_font_handle);
grtext_SetColor(GR_WHITE);
rend_ClearScreen(GR_BLACK);
rend_SetFlatColor(GR_WHITE);
rend_DrawLine(l,t,r,t);
rend_DrawLine(r,t,r,b);
rend_DrawLine(l,b,r,b);
rend_DrawLine(l,t,l,b);
rend_DrawLine(l, t, r, t);
rend_DrawLine(r, t, r, b);
rend_DrawLine(l, b, r, b);
rend_DrawLine(l, t, l, b);
grtext_CenteredPrintf(0,t+30, buf);
grtext_CenteredPrintf(0,b-30, "Press ENTER or ESC");
grtext_CenteredPrintf(0, t + 30, buf);
grtext_CenteredPrintf(0, b - 30, "Press ENTER or ESC");
grtext_Flush();
rend_EndFrame();
rend_Flip();
}
}
//////////////////////////////////////////////////////////////////////////////////////
#define COLOR_FONT 1
#define MONOCHROME_FONT 2
#define MAX_FONT_CHARS 256
static bool m_FontProp;
static uint8_t m_CharWidths[MAX_FONT_CHARS];
static int16_t m_CharHeight;
@@ -160,207 +146,194 @@ static int m_FontType;
static int m_FontBmW, m_FontBmH;
static uint16_t m_FgColor, m_BgColor, m_BoxColor;
#define PIX(_x,_y) m_FontBmData[(_x) + (_y) * m_FontBmW]
#define PIX(_x, _y) m_FontBmData[(_x) + (_y) * m_FontBmW]
int read_font_char(int cur_char, int& bmx, int& bmy)
{
int w,h,x,y;
int read_font_char(int cur_char, int &bmx, int &bmy) {
int w, h, x, y;
bool box_edge = false;
mprintf(0," %d-(%d,%d)",cur_char,bmx,bmy);
mprintf(0, " %d-(%d,%d)", cur_char, bmx, bmy);
while (PIX(bmx+1,bmy+1) == m_BoxColor)
bmx++; //deal with double-thick vertical lines
while (PIX(bmx + 1, bmy + 1) == m_BoxColor)
bmx++; // deal with double-thick vertical lines
for (w=0;PIX(bmx+1+w,bmy+1)!=m_BoxColor;w++)
{
if (PIX(bmx+1+w,bmy)!=m_BoxColor) {
for (w = 0; PIX(bmx + 1 + w, bmy + 1) != m_BoxColor; w++) {
if (PIX(bmx + 1 + w, bmy) != m_BoxColor) {
if (box_edge) {
message_box("Read probable premature eol at (%d,%d).\n", bmx+1+w, bmy);
message_box("Read probable premature eol at (%d,%d).\n", bmx + 1 + w, bmy);
w--;
return 2;
}
else {
message_box("Suspected error at pixel coordindates %d,%d (char %d)",bmx+1+w,bmy, cur_char);
} else {
message_box("Suspected error at pixel coordindates %d,%d (char %d)", bmx + 1 + w, bmy, cur_char);
return 0;
}
}
else {
} else {
box_edge = true;
}
}
box_edge = false;
for (h=0;PIX(bmx+1,bmy+1+h)!=m_BoxColor;h++)
{
if (PIX(bmx,bmy+1+h)!=m_BoxColor) {
for (h = 0; PIX(bmx + 1, bmy + 1 + h) != m_BoxColor; h++) {
if (PIX(bmx, bmy + 1 + h) != m_BoxColor) {
if (box_edge) {
message_box("Read probable premature end of row at (%d,%d) (pix=%04x,box=%04x).\n", bmx, bmy+1+h, PIX(bmx,bmy+1+h), m_BoxColor);
message_box("Read probable premature end of row at (%d,%d) (pix=%04x,box=%04x).\n", bmx, bmy + 1 + h,
PIX(bmx, bmy + 1 + h), m_BoxColor);
h--;
return 2;
}
else {
message_box("Suspected error at pixel coordindates %d,%d (char %d)",bmx,bmy+1+h, cur_char);
} else {
message_box("Suspected error at pixel coordindates %d,%d (char %d)", bmx, bmy + 1 + h, cur_char);
return 0;
}
}
else {
} else {
box_edge = true;
}
}
if (w==0 || h==0) {
message_box("Character %d has width of %d and height of %d",cur_char,w,h);
if (w == 0 || h == 0) {
message_box("Character %d has width of %d and height of %d", cur_char, w, h);
return 0;
}
if (w > 255 || w< 0) {
if (w > 255 || w < 0) {
message_box("Character %d has bad width %d (maximum=255)", cur_char, w);
return 0;
}
m_CharWidths[cur_char] = w;
if (m_CharMaxWidth !=0 && w != m_CharMaxWidth)
if (m_CharMaxWidth != 0 && w != m_CharMaxWidth)
m_FontProp = true;
if (w > m_CharMaxWidth) m_CharMaxWidth = w;
if (w > m_CharMaxWidth)
m_CharMaxWidth = w;
if (m_CharHeight == 0)
m_CharHeight = h;
else if (m_CharHeight != h) {
message_box("Char %d is wrong height (height = %d, correct height = %d)",cur_char,h,m_CharHeight);
message_box("Char %d is wrong height (height = %d, correct height = %d)", cur_char, h, m_CharHeight);
return 0;
}
for (y=0;y<h;y++)
for (x=0;x<w;x++)
{
for (y = 0; y < h; y++)
for (x = 0; x < w; x++) {
uint16_t c;
if ((c=PIX(bmx+1+x,bmy+1+y)) == m_BgColor)
if ((c = PIX(bmx + 1 + x, bmy + 1 + y)) == m_BgColor)
c = 0; // OLD COMMENT-must go back 565 pure green (old transparent)
else if (! (m_FgColor & 0xf000)) // 4444 check for alpha
else if (!(m_FgColor & 0xf000)) // 4444 check for alpha
m_FgColor = c;
else if (m_FgColor != c) { // OLD_COMMENT-c here is 1555 !! remember this.
m_FontType = COLOR_FONT; // mprintf(0, "%d,%d\n", bmx+1+x, bmy+1+y);
}
// if (c != 0)
// *m_DataPtr++ = c; // OLD COMMENT-here 555 pure green will turn into 565 pure green transparent.
// else
// if (c != 0)
// *m_DataPtr++ = c; // OLD
//COMMENT-here 555 pure green will turn into 565 pure green transparent. else
*m_DataPtr++ = c;
ASSERT(m_DataPtr < m_DataBuffer+(1024*256));
ASSERT(m_DataPtr < m_DataBuffer + (1024 * 256));
}
return 1;
}
int read_font_line(int cur_char, int& bmx, int& bmy)
{
while (bmx < m_FontBmW && PIX(bmx+1,bmy) == m_BoxColor)
{
int read_font_line(int cur_char, int &bmx, int &bmy) {
while (bmx < m_FontBmW && PIX(bmx + 1, bmy) == m_BoxColor) {
int res;
res = read_font_char(cur_char, bmx, bmy);
if (res == 0) return -1;
if (res == 0)
return -1;
else if (res == 1) {
bmx += m_CharWidths[cur_char]+1;
bmx += m_CharWidths[cur_char] + 1;
cur_char++;
}
else if (res == 2) {
} else if (res == 2) {
cur_char = -1;
break;
}
else break;
} else
break;
}
return cur_char;
}
bool extract_font(int bm_handle, tFontFileInfo *ft)
{
bool extract_font(int bm_handle, tFontFileInfo *ft) {
int bmx, bmy;
int cur_char;
// grab font template bitmap data from the bitmap library and retrieve characters
// store relevent information in file record.
// grab font template bitmap data from the bitmap library and retrieve characters
// store relevent information in file record.
m_FontBmData = bm_data(bm_handle, 0);
m_FontBmW = bm_w(bm_handle,0);
m_FontBmW = bm_w(bm_handle, 0);
m_FontBmH = bm_h(bm_handle, 0);
m_CharMaxWidth = m_CharHeight = 0;
m_FontProp = false;
m_FontType = MONOCHROME_FONT;
m_FgColor = NEW_TRANSPARENT_COLOR;
m_DataBuffer = new uint16_t[1024*MAX_FONT_CHARS];
m_DataBuffer = new uint16_t[1024 * MAX_FONT_CHARS];
m_DataPtr = m_DataBuffer;
// assume upper left pixel is background color, and first-found other
// color is box color
m_BgColor = PIX(0,0);
// assume upper left pixel is background color, and first-found other
// color is box color
m_BgColor = PIX(0, 0);
mprintf(0, "m_BgColor=%04x\n", m_BgColor);
for (bmy = 0;bmy < m_FontBmH; bmy++)
{
for (bmx = 0;bmx < m_FontBmW && PIX(bmx,bmy)==m_BgColor; bmx++) ;
if (PIX(bmx,bmy)!= m_BgColor) break;
for (bmy = 0; bmy < m_FontBmH; bmy++) {
for (bmx = 0; bmx < m_FontBmW && PIX(bmx, bmy) == m_BgColor; bmx++)
;
if (PIX(bmx, bmy) != m_BgColor)
break;
}
m_BoxColor = PIX(bmx,bmy);
m_BoxColor = PIX(bmx, bmy);
mprintf(0, "m_BoxColor=%04x\n", m_BoxColor);
// Get all data from current line.
// Get all data from current line.
mprintf(0, "Parsing font...");
mprintf(0," read_characters: ");
mprintf(0, " read_characters: ");
for (cur_char=0;bmy < m_FontBmH && cur_char<MAX_FONT_CHARS;)
{
for (cur_char = 0; bmy < m_FontBmH && cur_char < MAX_FONT_CHARS;) {
cur_char = read_font_line(cur_char, bmx, bmy);
if (cur_char == -1) {
delete[] m_DataBuffer;
m_DataBuffer = NULL;
return false;
}
bmy += m_CharHeight+1;
bmy += m_CharHeight + 1;
//search for start of next box
for (;bmy < m_FontBmH;bmy++) {
for (bmx = 0;bmx<m_FontBmW && PIX(bmx,bmy)!=m_BoxColor;bmx++) ;
if ((PIX(bmx,bmy)==m_BoxColor) && (PIX(bmx,bmy+1) == m_BoxColor))
// search for start of next box
for (; bmy < m_FontBmH; bmy++) {
for (bmx = 0; bmx < m_FontBmW && PIX(bmx, bmy) != m_BoxColor; bmx++)
;
if ((PIX(bmx, bmy) == m_BoxColor) && (PIX(bmx, bmy + 1) == m_BoxColor))
break;
}
if (bmy == m_FontBmH)
break;
// if (PIX(bmx,bmy+1) != m_BoxColor)
// break;
// if (PIX(bmx,bmy+1) != m_BoxColor)
// break;
}
mprintf(0, "\nDone!\n");
// now fill in font information & store it into our file record. this information
// can be used to save the font
// now fill in font information & store it into our file record. this information
// can be used to save the font
ft->width = m_CharMaxWidth;
ft->height = m_CharHeight;
ft->flags = (m_FontProp?FT_PROPORTIONAL:0) + ((m_FontType==COLOR_FONT)?FT_COLOR:0);
ft->flags = (m_FontProp ? FT_PROPORTIONAL : 0) + ((m_FontType == COLOR_FONT) ? FT_COLOR : 0);
ft->baseline = m_CharHeight;
ft->min_ascii = 0;
ft->max_ascii = cur_char-1;
ft->max_ascii = cur_char - 1;
ft->raw_data = (uint8_t *)m_DataBuffer;
ft->char_data = NULL;
ft->char_widths = m_CharWidths;
ft->kern_data= NULL;
ft->kern_data = NULL;
ft->flags |= FT_FMT4444;
return true;
}
//////////////////////////////////////////////////////////////////////////////////////////
// Font file format.
//
@@ -375,10 +348,8 @@ bool extract_font(int bm_handle, tFontFileInfo *ft)
// no kerning.
// store font data.
void FontCreate(const char *fnt_file_source, const char *fnt_file_dest, int min_ascii)
{
// import font
void FontCreate(const char *fnt_file_source, const char *fnt_file_dest, int min_ascii) {
// import font
FONTFILE ffile;
tFontFileInfo ft;
int bm_handle;
@@ -391,35 +362,35 @@ void FontCreate(const char *fnt_file_source, const char *fnt_file_dest, int min_
Error("Couldn't open %s for extraction.", fnt_file_source);
}
// Get MinAscii and other needed info before extracting font.
// Get MinAscii and other needed info before extracting font.
if (!extract_font(bm_handle, &ft)) {
Error("Unable to generate font from %s.", fnt_file_source);
return;
}
///////////////////////////////////////////////////////////////////////////////
// Adjust font record for file write.
///////////////////////////////////////////////////////////////////////////////
// Adjust font record for file write.
int num_char;
ft.kern_data= NULL;
ft.kern_data = NULL;
ft.min_ascii = min_ascii;
ft.max_ascii = ft.min_ascii + ft.max_ascii;
// add newstyle variables here.
// add newstyle variables here.
ft.flags |= FT_FFI2;
ft.ffi2.tracking = 0;
// write to file
// write to file
mprintf(0, "Saving font data...");
ffile = OPEN_FONT((char *)fnt_file_dest);
if (!ffile) {
Error("Unable to save font %s.", fnt_file_dest);
}
// Write file id.
// Write file id.
WRITE_FONT_INT(ffile, 0xfeedbaba);
// Write Header
// Write Header
ft.baseline = 0;
WRITE_FONT_SHORT(ffile, ft.width);
@@ -431,48 +402,46 @@ void FontCreate(const char *fnt_file_source, const char *fnt_file_dest, int min_
WRITE_FONT_DATA(ffile, fontname, 32, 1);
WRITE_FONT_SHORT(ffile, (int16_t)ft.ffi2.tracking);
WRITE_FONT_DATA(ffile, ft.ffi2.reserved, sizeof(ft.ffi2.reserved),1);
WRITE_FONT_DATA(ffile, ft.ffi2.reserved, sizeof(ft.ffi2.reserved), 1);
num_char = (int)(ft.max_ascii - ft.min_ascii + 1);
// Write widths now if necessary.(FT_PROPORTIONAL)
// Write widths now if necessary.(FT_PROPORTIONAL)
if (ft.flags & FT_PROPORTIONAL) {
for (int i = 0; i < num_char; i++)
WRITE_FONT_SHORT(ffile, ft.char_widths[i]);
}
if (ft.flags & FT_COLOR) {
WRITE_FONT_INT(ffile, (int)(m_DataPtr-m_DataBuffer)*sizeof(uint16_t));
WRITE_FONT_DATA(ffile, (uint8_t *)m_DataBuffer, (m_DataPtr-m_DataBuffer)*sizeof(uint16_t), 1);
}
else {
WRITE_FONT_INT(ffile, (int)(m_DataPtr - m_DataBuffer) * sizeof(uint16_t));
WRITE_FONT_DATA(ffile, (uint8_t *)m_DataBuffer, (m_DataPtr - m_DataBuffer) * sizeof(uint16_t), 1);
} else {
// bitpack for mono font storage:: 16bpp -> 8 bits/1 byte
int i,x,y,w,cnt=0;
int i, x, y, w, cnt = 0;
uint16_t *p = m_DataBuffer;
uint8_t *bits;
bits = (uint8_t *)mem_malloc(256 * MAX_FONT_CHARS);
for (i = 0; i < num_char; i++)
{
for (y = 0; y < ft.height; y++)
{
for (i = 0; i < num_char; i++) {
for (y = 0; y < ft.height; y++) {
uint8_t mask, datum;
w = (ft.flags & FT_PROPORTIONAL) ? ft.char_widths[i] : ft.width;
ASSERT(w <= 48); // Max width size shall be 32 pixels
mask = 0x80; datum = 0;
mask = 0x80;
datum = 0;
for (x = 0; x < w; x++)
{
for (x = 0; x < w; x++) {
if (mask == 0) {
bits[cnt++] = datum;
datum = 0;
mask = 0x80;
}
if (*p++ != 0x07e0) datum |= mask;
if (*p++ != 0x07e0)
datum |= mask;
mask >>= 1;
}
@@ -485,61 +454,60 @@ void FontCreate(const char *fnt_file_source, const char *fnt_file_dest, int min_
mem_free(bits);
}
// We should add kerning support here.
// We should add kerning support here.
// Close font.
// Close font.
CLOSE_FONT(ffile);
delete[] m_DataBuffer; // allocated in extract_font!
bm_FreeBitmap(bm_handle);
int new_font_handle = grfont_Load((char*)fnt_file_dest);
int new_font_handle = grfont_Load((char *)fnt_file_dest);
if (new_font_handle < 0) {
message_box("New font failed to load!");
}
// print out stats.
while (1)
{
int x,y,i;
// print out stats.
while (1) {
int x, y, i;
FontDoIO();
if (ddio_KeyInKey() == KEY_ENTER) {
break;
}
rend_StartFrame(0,0,FIXED_SCREEN_WIDTH, FIXED_SCREEN_HEIGHT);
grtext_SetParameters(0,0,FIXED_SCREEN_WIDTH,FIXED_SCREEN_HEIGHT);
rend_StartFrame(0, 0, FIXED_SCREEN_WIDTH, FIXED_SCREEN_HEIGHT);
grtext_SetParameters(0, 0, FIXED_SCREEN_WIDTH, FIXED_SCREEN_HEIGHT);
grtext_SetFont(System_font_handle);
grtext_SetColor(GR_WHITE);
rend_ClearScreen(GR_BLACK);
grtext_Printf(0,12, "Created font:\2\65 %s", fnt_file_dest);
grtext_Printf(0,28, "Type:\2\65 %s, %s", (ft.flags & FT_COLOR) ? "COLOR" : "MONO", (ft.flags & FT_PROPORTIONAL) ? "PROPORTIONAL" : "FIXED WIDTH");
grtext_Printf(0,40, "Ascii:\2\65 %d to %d", ft.min_ascii,ft.max_ascii);
grtext_Printf(0,52, "Maxwidth:\2\65 %d", ft.width);
grtext_Printf(0,64, "Maxheight:\2\65 %d", ft.height);
grtext_Printf(0, 12, "Created font:\2\65 %s", fnt_file_dest);
grtext_Printf(0, 28, "Type:\2\65 %s, %s", (ft.flags & FT_COLOR) ? "COLOR" : "MONO",
(ft.flags & FT_PROPORTIONAL) ? "PROPORTIONAL" : "FIXED WIDTH");
grtext_Printf(0, 40, "Ascii:\2\65 %d to %d", ft.min_ascii, ft.max_ascii);
grtext_Printf(0, 52, "Maxwidth:\2\65 %d", ft.width);
grtext_Printf(0, 64, "Maxheight:\2\65 %d", ft.height);
grtext_Printf(0,FIXED_SCREEN_HEIGHT-20, "Press ENTER to quit.");
grtext_Printf(0, FIXED_SCREEN_HEIGHT - 20, "Press ENTER to quit.");
// spew new font.
x=10; y = 120;
x = 10;
y = 120;
grtext_SetFont(new_font_handle);
for (i = ft.min_ascii; i <= ft.max_ascii; i++)
{
for (i = ft.min_ascii; i <= ft.max_ascii; i++) {
char str[2];
str[0] = i;
str[1] = 0;
if ((x+grfont_GetCharWidth(new_font_handle, i)) > FIXED_SCREEN_WIDTH) {
if ((x + grfont_GetCharWidth(new_font_handle, i)) > FIXED_SCREEN_WIDTH) {
x = 10;
y += grfont_GetHeight(new_font_handle)+1;
y += grfont_GetHeight(new_font_handle) + 1;
}
grtext_Puts(x,y,str);
x+= grfont_GetCharWidth(new_font_handle, i)+1;
grtext_Puts(x, y, str);
x += grfont_GetCharWidth(new_font_handle, i) + 1;
}
grtext_Flush();
@@ -550,9 +518,7 @@ void FontCreate(const char *fnt_file_source, const char *fnt_file_dest, int min_
grfont_Free(new_font_handle);
}
void FontView(const char *fnt_file_name)
{
void FontView(const char *fnt_file_name) {
tFontTemplate ft;
int new_font_handle;
@@ -563,10 +529,9 @@ void FontView(const char *fnt_file_name)
grfont_LoadTemplate((char *)fnt_file_name, &ft);
ddio_KeyFlush();
// print out stats.
while (1)
{
int x,y,i;
// print out stats.
while (1) {
int x, y, i;
FontDoIO();
@@ -574,50 +539,48 @@ void FontView(const char *fnt_file_name)
break;
}
rend_StartFrame(0,0,FIXED_SCREEN_WIDTH, FIXED_SCREEN_HEIGHT);
grtext_SetParameters(0,0,FIXED_SCREEN_WIDTH,FIXED_SCREEN_HEIGHT);
rend_StartFrame(0, 0, FIXED_SCREEN_WIDTH, FIXED_SCREEN_HEIGHT);
grtext_SetParameters(0, 0, FIXED_SCREEN_WIDTH, FIXED_SCREEN_HEIGHT);
grtext_SetFont(System_font_handle);
grtext_SetColor(GR_WHITE);
rend_ClearScreen(GR_BLACK);
grtext_Printf(0,12, "Font:\2\65 %s", fnt_file_name);
grtext_Printf(0,28, "Type:\2\65 %s, %s, %s", (ft.monochromatic ? "MONO" : "COLOR"), (ft.proportional ? "PROPORTIONAL" : "FIXED WIDTH"),
(ft.newstyle ? "4444" : "1555"));
grtext_Printf(0,40, "Ascii:\2\65 %d to %d", ft.min_ascii,ft.max_ascii);
grtext_Printf(0,52, "Maxwidth:\2\65 %d", ft.ch_maxwidth);
grtext_Printf(0,64, "Maxheight:\2\65 %d", ft.ch_height);
grtext_Printf(0, 12, "Font:\2\65 %s", fnt_file_name);
grtext_Printf(0, 28, "Type:\2\65 %s, %s, %s", (ft.monochromatic ? "MONO" : "COLOR"),
(ft.proportional ? "PROPORTIONAL" : "FIXED WIDTH"), (ft.newstyle ? "4444" : "1555"));
grtext_Printf(0, 40, "Ascii:\2\65 %d to %d", ft.min_ascii, ft.max_ascii);
grtext_Printf(0, 52, "Maxwidth:\2\65 %d", ft.ch_maxwidth);
grtext_Printf(0, 64, "Maxheight:\2\65 %d", ft.ch_height);
if (ft.ffi2) {
grtext_Printf(0,76, "Tracking:\2\65 %d", (int)ft.ch_tracking);
grtext_Printf(0, 76, "Tracking:\2\65 %d", (int)ft.ch_tracking);
}
grtext_Printf(0,FIXED_SCREEN_HEIGHT-20, "Press ENTER to quit.");
grtext_Printf(0, FIXED_SCREEN_HEIGHT - 20, "Press ENTER to quit.");
// spew new font.
x=10; y = 120;
x = 10;
y = 120;
grtext_SetFont(new_font_handle);
for (i = ft.min_ascii; i <= ft.max_ascii; i++)
{
for (i = ft.min_ascii; i <= ft.max_ascii; i++) {
char str[2];
str[0] = i;
str[1] = 0;
if ((x+grfont_GetCharWidth(new_font_handle, i)) > FIXED_SCREEN_WIDTH) {
if ((x + grfont_GetCharWidth(new_font_handle, i)) > FIXED_SCREEN_WIDTH) {
x = 10;
y += grfont_GetHeight(new_font_handle)+1;
y += grfont_GetHeight(new_font_handle) + 1;
}
grtext_Puts(x,y,str);
x+= grfont_GetCharWidth(new_font_handle, i)+1;
grtext_Puts(x, y, str);
x += grfont_GetCharWidth(new_font_handle, i) + 1;
}
grtext_Flush();
rend_EndFrame();
rend_Flip();
}
grfont_Free(new_font_handle);

View File

@@ -71,18 +71,15 @@ extern void FontCreate(const char *fnt_file_source, const char *fnt_file_dest, i
class oeApplication *FontEditor = NULL;
int System_font_handle = -1;
class appFontKerner: public oeWin32Application
{
class appFontKerner : public oeWin32Application {
bool shutdown;
public:
appFontKerner(HINSTANCE hinst): oeWin32Application(APPNAME, OEAPP_FULLSCREEN, hinst) { shutdown = false; };
appFontKerner(HINSTANCE hinst) : oeWin32Application(APPNAME, OEAPP_FULLSCREEN, hinst) { shutdown = false; };
// returns 0 if we pass to default window handler.
virtual int WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
// returns 0 if we pass to default window handler.
virtual int WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
switch (msg) {
case WM_ACTIVATEAPP:
if (wParam == (unsigned)(FALSE) && !shutdown && FontEditor) {
shutdown = true;
@@ -90,8 +87,7 @@ public:
ddio_Close();
ShowWindow((HWND)hwnd, SW_MINIMIZE);
this->deactivate();
}
else if (wParam == (unsigned)(TRUE) && shutdown && FontEditor) {
} else if (wParam == (unsigned)(TRUE) && shutdown && FontEditor) {
this->activate();
ShowWindow((HWND)hwnd, SW_MAXIMIZE);
InitIO(this);
@@ -99,21 +95,13 @@ public:
shutdown = false;
}
break;
}
return oeWin32Application::WndProc(hwnd, msg, wParam, lParam);
};
};
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
appFontKerner fontkern(hInstance);
int i;
@@ -122,27 +110,28 @@ int APIENTRY WinMain(HINSTANCE hInstance,
GatherArgs(lpCmdLine);
i = FindArg("-glide");
if (i) Preferred_renderer = RENDERER_GLIDE;
if (i)
Preferred_renderer = RENDERER_GLIDE;
i = FindArg("-create");
if (i) {
int min_ascii = atoi(GameArgs[i+3]);
int min_ascii = atoi(GameArgs[i + 3]);
InitSystems(&fontkern, false, false, Preferred_renderer);
FontCreate(GameArgs[i+1], GameArgs[i+2], min_ascii);
FontCreate(GameArgs[i + 1], GameArgs[i + 2], min_ascii);
return 0;
}
i = FindArg("-kern");
if (i) {
InitSystems(&fontkern, false, false, Preferred_renderer);
FontKern(GameArgs[i+1]);
FontKern(GameArgs[i + 1]);
return 0;
}
i = FindArg("-view");
if (i) {
InitSystems(&fontkern, false, false, Preferred_renderer);
FontView(GameArgs[i+1]);
FontView(GameArgs[i + 1]);
return 0;
}
@@ -155,22 +144,21 @@ int APIENTRY WinMain(HINSTANCE hInstance,
InitIO(&fontkern);
grfont_Reset();
grtext_Init();
FontKernDump(GameArgs[i+1]);
FontKernDump(GameArgs[i + 1]);
return 0;
}
MessageBox(NULL, "Need to specify a font to edit.", "Error",MB_OK);
MessageBox(NULL, "Need to specify a font to edit.", "Error", MB_OK);
return 0;
}
void InitSystems(oeApplication *app, bool debug, bool mono, renderer_type renderer)
{
void InitSystems(oeApplication *app, bool debug, bool mono, renderer_type renderer) {
error_Init(debug, mono, APPNAME);
SetMessageBoxTitle(APPNAME " Message");
mem_Init(); InitIO(app);
mem_Init();
InitIO(app);
cf_OpenLibrary("fonteditor.hog");
bm_InitBitmaps();
@@ -186,9 +174,7 @@ void InitSystems(oeApplication *app, bool debug, bool mono, renderer_type render
FontEditor = app;
}
void InitIO(oeApplication *app)
{
void InitIO(oeApplication *app) {
char path[1024];
ddio_init_info ddio_init_data;
@@ -200,12 +186,10 @@ void InitIO(oeApplication *app)
ddio_Init(&ddio_init_data);
GetCurrentDirectory(sizeof(path), path);
cf_SetSearchPath(path,NULL);
cf_SetSearchPath(path, NULL);
}
void InitRenderer(oeApplication *app, renderer_type renderer)
{
void InitRenderer(oeApplication *app, renderer_type renderer) {
renderer_preferred_state req_renderer_state;
req_renderer_state.width = FIXED_SCREEN_WIDTH;
@@ -221,9 +205,7 @@ void InitRenderer(oeApplication *app, renderer_type renderer)
}
}
void FontDoIO()
{
void FontDoIO() {
FontEditor->defer();
ddio_Frame();
}

View File

@@ -41,4 +41,3 @@ extern void FontView(const char *fnt_file_name);
extern void FontCreate(const char *fnt_file_source, const char *fnt_file_dest, int min_ascii);
extern int System_font_handle;

View File

@@ -48,48 +48,42 @@
#include <stdio.h>
#include <stdlib.h>
chunked_bitmap Editor_bkg;
tFontTemplate Font_template;
char *SampleText = "This is some sample text that is here to\n" \
"Show you how the antialiasing will\n" \
"look over different color backgrounds\n" \
"KERN PAIRS: VaWaVeWeVAV-LyT.T,TyTvTcYe\n";
char *SampleText = "This is some sample text that is here to\n"
"Show you how the antialiasing will\n"
"look over different color backgrounds\n"
"KERN PAIRS: VaWaVeWeVAV-LyT.T,TyTvTcYe\n";
// this function determines if a kerning pair exists in the current font template
// if there is no kerning structure, add it. if no kerning in font, add it to the template
#define KERNINFO_PAIR_SIZE 3
int fonttool_get_kerning( int c1, int c2, int *pairnum=NULL);
int fonttool_get_kerning(int c1, int c2, int *pairnum = NULL);
int fonttool_get_kerning( int c1, int c2, int *pairnum)
{
int fonttool_get_kerning(int c1, int c2, int *pairnum) {
int i;
uint8_t *kern_data;
kern_data= Font_template.kern_data;
kern_data = Font_template.kern_data;
if (kern_data) {
i=0;
while (kern_data[i] != 255)
{
if (kern_data[i] == (uint8_t)c1 && kern_data[i+1] == (uint8_t)c2) {
if (pairnum) *pairnum = i/3;
return (int)((int8_t)kern_data[i+2]);
i = 0;
while (kern_data[i] != 255) {
if (kern_data[i] == (uint8_t)c1 && kern_data[i + 1] == (uint8_t)c2) {
if (pairnum)
*pairnum = i / 3;
return (int)((int8_t)kern_data[i + 2]);
}
i+=KERNINFO_PAIR_SIZE;
i += KERNINFO_PAIR_SIZE;
}
}
return 0;
}
void fonttool_set_kerning( int c1, int c2, int dist )
{
int i,j;
void fonttool_set_kerning(int c1, int c2, int dist) {
int i, j;
uint8_t *kern_data;
if (c1 == 255 || c2 == 255) {
@@ -97,11 +91,11 @@ void fonttool_set_kerning( int c1, int c2, int dist )
return;
}
kern_data= Font_template.kern_data;
kern_data = Font_template.kern_data;
if (!kern_data) {
// create a one entry kern table.
kern_data = (uint8_t *)mem_malloc(KERNINFO_PAIR_SIZE*2);
kern_data = (uint8_t *)mem_malloc(KERNINFO_PAIR_SIZE * 2);
kern_data[0] = (uint8_t)c1;
kern_data[1] = (uint8_t)c2;
kern_data[2] = (int8_t)dist;
@@ -109,83 +103,74 @@ void fonttool_set_kerning( int c1, int c2, int dist )
kern_data[4] = 255;
kern_data[5] = 0;
Font_template.kern_data = kern_data;
mprintf(0, "adding first kerning pair %d,%d\n", c1,c2);
mprintf(0, "adding first kerning pair %d,%d\n", c1, c2);
return;
}
// check for match in current list.
i=0;
while (kern_data[i] != 255)
{
if (kern_data[i] == (uint8_t)c1 && kern_data[i+1] == (uint8_t)c2) {
kern_data[i+2] = (int8_t)dist;
// check for match in current list.
i = 0;
while (kern_data[i] != 255) {
if (kern_data[i] == (uint8_t)c1 && kern_data[i + 1] == (uint8_t)c2) {
kern_data[i + 2] = (int8_t)dist;
if (dist == 0) {
// remove this kerning pair.
j = i;
do
{
kern_data[j] = kern_data[j+3];
kern_data[j+1] = kern_data[j+4];
kern_data[j+2] = kern_data[j+5];
j+= KERNINFO_PAIR_SIZE;
}
while (kern_data[j] != 255);
do {
kern_data[j] = kern_data[j + 3];
kern_data[j + 1] = kern_data[j + 4];
kern_data[j + 2] = kern_data[j + 5];
j += KERNINFO_PAIR_SIZE;
} while (kern_data[j] != 255);
if (i == 0) {
// last pair, deallocate kern_data and end.
mprintf(0, "removing last kerning pair\n");
mem_free(kern_data);
kern_data = NULL;
}
else {
mprintf(0, "removing kerning pair %d,%d\n", c1,c2);
} else {
mprintf(0, "removing kerning pair %d,%d\n", c1, c2);
}
}
Font_template.kern_data = kern_data;
return;
}
i+=KERNINFO_PAIR_SIZE;
i += KERNINFO_PAIR_SIZE;
}
// new entry.
// new entry.
uint8_t *new_kern_data;
int n_pairs = i/KERNINFO_PAIR_SIZE;
int n_pairs = i / KERNINFO_PAIR_SIZE;
new_kern_data = (uint8_t *)mem_malloc((n_pairs+2)*sizeof(uint8_t)*KERNINFO_PAIR_SIZE);
for (i = 0; i < n_pairs; i++)
{
new_kern_data[i*KERNINFO_PAIR_SIZE] = kern_data[i*3];
new_kern_data[i*KERNINFO_PAIR_SIZE+1] = kern_data[i*3+1];
new_kern_data[i*KERNINFO_PAIR_SIZE+2] = kern_data[i*3+2];
new_kern_data = (uint8_t *)mem_malloc((n_pairs + 2) * sizeof(uint8_t) * KERNINFO_PAIR_SIZE);
for (i = 0; i < n_pairs; i++) {
new_kern_data[i * KERNINFO_PAIR_SIZE] = kern_data[i * 3];
new_kern_data[i * KERNINFO_PAIR_SIZE + 1] = kern_data[i * 3 + 1];
new_kern_data[i * KERNINFO_PAIR_SIZE + 2] = kern_data[i * 3 + 2];
}
new_kern_data[i*KERNINFO_PAIR_SIZE] = (uint8_t)c1;
new_kern_data[i*KERNINFO_PAIR_SIZE+1] = (uint8_t)c2;
new_kern_data[i*KERNINFO_PAIR_SIZE+2] = (int8_t)dist;
new_kern_data[i * KERNINFO_PAIR_SIZE] = (uint8_t)c1;
new_kern_data[i * KERNINFO_PAIR_SIZE + 1] = (uint8_t)c2;
new_kern_data[i * KERNINFO_PAIR_SIZE + 2] = (int8_t)dist;
i++;
new_kern_data[i*KERNINFO_PAIR_SIZE] = 255;
new_kern_data[i*KERNINFO_PAIR_SIZE+1] = 255;
new_kern_data[i*KERNINFO_PAIR_SIZE+2] = 0;
new_kern_data[i * KERNINFO_PAIR_SIZE] = 255;
new_kern_data[i * KERNINFO_PAIR_SIZE + 1] = 255;
new_kern_data[i * KERNINFO_PAIR_SIZE + 2] = 0;
mem_free(kern_data);
Font_template.kern_data = new_kern_data;
mprintf(0, "adding first kerning pair %d,%d (total=%d)\n", c1,c2, n_pairs+1);
mprintf(0, "adding first kerning pair %d,%d (total=%d)\n", c1, c2, n_pairs + 1);
}
void fonttool_remove_kerning()
{
void fonttool_remove_kerning() {
if (Font_template.kern_data) {
mem_free(Font_template.kern_data);
Font_template.kern_data = NULL;
}
}
/////////////////////////////////////////////////////////////////////////////
void FontKern(const char *fnt_file_name)
{
void FontKern(const char *fnt_file_name) {
int bm_handle;
int font_handle;
int c1 = 'b', c2 = 'u', d;
@@ -194,13 +179,13 @@ void FontKern(const char *fnt_file_name)
int current_item = 0;
int num_items_displayed = 1;
bool done = false;
int16_t text_alpha=255;
int red_comp , green_comp, blue_comp;
int16_t text_alpha = 255;
int red_comp, green_comp, blue_comp;
ddgr_color text_color;
red_comp = green_comp = blue_comp = 255;
bm_handle = bm_AllocLoadFileBitmap("FontTool.ogf",0);
bm_handle = bm_AllocLoadFileBitmap("FontTool.ogf", 0);
if (bm_handle <= BAD_BITMAP_HANDLE) {
Error("Error loading FontEditor art.");
}
@@ -209,7 +194,7 @@ void FontKern(const char *fnt_file_name)
}
bm_FreeBitmap(bm_handle);
// load font into memory.
// load font into memory.
font_handle = grfont_Load((char *)fnt_file_name);
if (font_handle < 0) {
Error("Error loading font %s", fnt_file_name);
@@ -225,22 +210,19 @@ void FontKern(const char *fnt_file_name)
if (Font_template.kern_data) {
current_pair = 0;
}
else {
} else {
current_pair = -1;
}
last_good_pair = current_pair;
while(!done)
{
while (!done) {
int key;
FontDoIO();
key = ddio_KeyInKey();
switch (key)
{
switch (key) {
case KEY_ESC:
done = true;
break;
@@ -290,60 +272,66 @@ void FontKern(const char *fnt_file_name)
case KEY_COMMA:
text_alpha -= 16;
if (text_alpha < 0) text_alpha = 0;
if (text_alpha < 0)
text_alpha = 0;
break;
case KEY_PERIOD:
text_alpha += 16;
if (text_alpha > 255) text_alpha = 255;
if (text_alpha > 255)
text_alpha = 255;
break;
case KEY_PAD7:
c1++;
if (c1 > Font_template.max_ascii) c1 = Font_template.min_ascii;
if (c1 > Font_template.max_ascii)
c1 = Font_template.min_ascii;
break;
case KEY_PAD9:
c2++;
if (c2 > Font_template.max_ascii) c2 = Font_template.min_ascii;
if (c2 > Font_template.max_ascii)
c2 = Font_template.min_ascii;
break;
case KEY_PAD1:
c1--;
if (c1 < Font_template.min_ascii) c1 = Font_template.max_ascii;
if (c1 < Font_template.min_ascii)
c1 = Font_template.max_ascii;
break;
case KEY_PAD3:
c2--;
if (c2 < Font_template.min_ascii) c2 = Font_template.max_ascii;
if (c2 < Font_template.min_ascii)
c2 = Font_template.max_ascii;
break;
case KEY_PAD4:
d = fonttool_get_kerning(c1,c2);
fonttool_set_kerning(c1, c2, d-1);
d = fonttool_get_kerning(c1, c2);
fonttool_set_kerning(c1, c2, d - 1);
grfont_SetKerning(font_handle, Font_template.kern_data);
break;
case KEY_PAD5:
fonttool_set_kerning(c1,c2,0);
fonttool_set_kerning(c1, c2, 0);
break;
case KEY_PAD6:
d = fonttool_get_kerning(c1,c2);
fonttool_set_kerning(c1,c2,d+1);
d = fonttool_get_kerning(c1, c2);
fonttool_set_kerning(c1, c2, d + 1);
grfont_SetKerning(font_handle, Font_template.kern_data);
break;
case KEY_PAD2:
if ( current_pair < 0 ) {
if (current_pair < 0) {
current_pair = last_good_pair;
}
if (current_pair >= 0) {
uint8_t *kern_data = &Font_template.kern_data[current_pair*3];
uint8_t *kern_data = &Font_template.kern_data[current_pair * 3];
if (kern_data[3] != 255) {
current_pair++;
kern_data = &Font_template.kern_data[current_pair*3];
kern_data = &Font_template.kern_data[current_pair * 3];
}
c1 = kern_data[0];
c2 = kern_data[1];
@@ -351,16 +339,16 @@ void FontKern(const char *fnt_file_name)
break;
case KEY_PAD8:
if ( current_pair < 0 ) {
if (current_pair < 0) {
current_pair = last_good_pair;
}
if (current_pair >= 0) {
uint8_t *kern_data = &Font_template.kern_data[current_pair*3];
uint8_t *kern_data = &Font_template.kern_data[current_pair * 3];
if (kern_data != Font_template.kern_data) {
// gosh, comparing pointers like this may not be the best method...this is shitty code...
current_pair--;
kern_data = &Font_template.kern_data[current_pair*3];
kern_data = &Font_template.kern_data[current_pair * 3];
}
c1 = kern_data[0];
c2 = kern_data[1];
@@ -381,8 +369,8 @@ void FontKern(const char *fnt_file_name)
// draw.
text_color = GR_RGB(red_comp, green_comp, blue_comp);
rend_StartFrame(0,0,FIXED_SCREEN_WIDTH,FIXED_SCREEN_HEIGHT,0);
grtext_SetParameters(0,0,FIXED_SCREEN_WIDTH,FIXED_SCREEN_HEIGHT);
rend_StartFrame(0, 0, FIXED_SCREEN_WIDTH, FIXED_SCREEN_HEIGHT, 0);
grtext_SetParameters(0, 0, FIXED_SCREEN_WIDTH, FIXED_SCREEN_HEIGHT);
grtext_SetFont(font_handle);
grtext_SetColor(text_color);
grtext_SetAlpha((uint8_t)text_alpha);
@@ -390,8 +378,8 @@ void FontKern(const char *fnt_file_name)
rend_ClearScreen(GR_BLACK);
rend_DrawChunkedBitmap(&Editor_bkg, 0, 0, 255);
grtext_Printf(240,210,"%c (%d)", c1, c1);
grtext_Printf(340,210,"%c (%d)", c2, c2);
grtext_Printf(240, 210, "%c (%d)", c1, c1);
grtext_Printf(340, 210, "%c (%d)", c2, c2);
grtext_CenteredPrintf(0, 240, "Ham%c%crger", c1, c2);
@@ -403,69 +391,82 @@ void FontKern(const char *fnt_file_name)
int th;
th = grtext_GetTextHeight(SampleText);
grtext_Printf(10,350,SampleText);
grtext_Printf(10,350+th+10, SampleText);
grtext_Printf(10, 350, SampleText);
grtext_Printf(10, 350 + th + 10, SampleText);
}
// display kerned pairs.
int x = 5, y = 200, i, n, widest=0;
int n_pairs=0, stop;
int tmpp=-1;
int x = 5, y = 200, i, n, widest = 0;
int n_pairs = 0, stop;
int tmpp = -1;
char kerntext[16];
if (Font_template.kern_data) {
i=0;
while (Font_template.kern_data[i] != 255)
{
i = 0;
while (Font_template.kern_data[i] != 255) {
n_pairs++;
i+=KERNINFO_PAIR_SIZE;
i += KERNINFO_PAIR_SIZE;
}
}
// update current pair values
if ( current_pair >= n_pairs ) {
if (current_pair >= n_pairs) {
current_pair = -1;
}
fonttool_get_kerning(c1, c2, &tmpp );
fonttool_get_kerning(c1, c2, &tmpp);
if ( tmpp != -1 ) {
if (tmpp != -1) {
current_pair = tmpp;
} else {
if ( current_pair > -1 )
if (current_pair > -1)
last_good_pair = current_pair;
current_pair = -1;
}
if (current_pair > -1) { current_item = current_pair; }
if (current_item < 0) { current_item = 0; }
if (current_item >= n_pairs) { current_item = n_pairs-1; }
if (current_item < first_item) { first_item = current_item; }
if (current_item >= (first_item+num_items_displayed)) { first_item = current_item-num_items_displayed+1; }
if (n_pairs <= num_items_displayed) { first_item = 0; }
stop = first_item+num_items_displayed;
if (stop>n_pairs) stop = n_pairs;
if (current_pair > -1) {
current_item = current_pair;
}
if (current_item < 0) {
current_item = 0;
}
if (current_item >= n_pairs) {
current_item = n_pairs - 1;
}
if (current_item < first_item) {
first_item = current_item;
}
if (current_item >= (first_item + num_items_displayed)) {
first_item = current_item - num_items_displayed + 1;
}
if (n_pairs <= num_items_displayed) {
first_item = 0;
}
stop = first_item + num_items_displayed;
if (stop > n_pairs)
stop = n_pairs;
for (i=first_item,n=0; i<stop; i++)
{
int tw,th;
for (i = first_item, n = 0; i < stop; i++) {
int tw, th;
ASSERT(Font_template.kern_data);
uint8_t *kern_data = &Font_template.kern_data[i*3];
if (i==current_pair) {
rend_SetFlatColor(GR_RGB(255,0,0));
rend_DrawLine(x,y,x+6,y+5);
rend_DrawLine(x+6,y+5,x,y+8);
rend_DrawLine(x,y+8,x,y);
uint8_t *kern_data = &Font_template.kern_data[i * 3];
if (i == current_pair) {
rend_SetFlatColor(GR_RGB(255, 0, 0));
rend_DrawLine(x, y, x + 6, y + 5);
rend_DrawLine(x + 6, y + 5, x, y + 8);
rend_DrawLine(x, y + 8, x, y);
}
sprintf(kerntext, "%c%c", kern_data[0], kern_data[1]);
grtext_Puts(x+8,y,kerntext);
grtext_Puts(x + 8, y, kerntext);
n++;
tw = grtext_GetTextLineWidth(kerntext) + 8;
th = grtext_GetTextHeight(kerntext);
if (tw > widest) {widest = tw; }
if (tw > widest) {
widest = tw;
}
y += th;
if (y > 330) {
y = 200;
x += widest+5;
x += widest + 5;
if (x > 150) {
num_items_displayed = n;
break;
@@ -473,10 +474,15 @@ void FontKern(const char *fnt_file_name)
widest = 0;
}
}
if (i == stop) { num_items_displayed++; }
if (num_items_displayed < 1) {num_items_displayed = 1;}
if (num_items_displayed > n_pairs) { num_items_displayed = n_pairs; }
if (i == stop) {
num_items_displayed++;
}
if (num_items_displayed < 1) {
num_items_displayed = 1;
}
if (num_items_displayed > n_pairs) {
num_items_displayed = n_pairs;
}
grtext_Flush();
rend_EndFrame();
@@ -488,10 +494,7 @@ void FontKern(const char *fnt_file_name)
bm_DestroyChunkedBitmap(&Editor_bkg);
}
void FontKernDump(const char *fnt_file_name)
{
void FontKernDump(const char *fnt_file_name) {
if (!grfont_LoadTemplate((char *)fnt_file_name, &Font_template)) {
Error("Error loading font template %s", fnt_file_name);
}
@@ -504,13 +507,12 @@ void FontKernDump(const char *fnt_file_name)
fp = fopen(filename, "wt");
if (fp) {
uint8_t *kern_data = Font_template.kern_data;
while (kern_data[0] != 255)
{
while (kern_data[0] != 255) {
uint8_t c1 = kern_data[0];
uint8_t c2 = kern_data[1];
int8_t delta = (int8_t)kern_data[2];
fprintf(fp, "%c %c => %d spacing\n", c1,c2,(int)delta);
fprintf(fp, "%c %c => %d spacing\n", c1, c2, (int)delta);
kern_data += 3;
}
fclose(fp);

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// stdafx.cpp : source file that includes just the standard includes
// FontEditor.pch will be the pre-compiled header

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
@@ -30,7 +30,6 @@
#include <windows.h>
// TODO: reference additional headers your program requires here
//{{AFX_INSERT_LOCATION}}

View File

@@ -35,70 +35,60 @@
#include "mono.h"
#include <string.h>
static int TotalArgs=0;
static int TotalArgs = 0;
char GameArgs[MAX_ARGS][MAX_CHARS_PER_ARG];
// Gathers all arguments
void GatherArgs (const char *str)
{
int i,t,curarg=1;
int len=strlen(str);
void GatherArgs(const char *str) {
int i, t, curarg = 1;
int len = strlen(str);
bool gotquote = false;
for (t=0,i=0;i<len;i++)
{
if(t==0)
{
if(str[i]=='\"')
{
for (t = 0, i = 0; i < len; i++) {
if (t == 0) {
if (str[i] == '\"') {
gotquote = true;
continue;
}
}
if(gotquote)
{
if (str[i]!='\"' && str[i]!=0)
GameArgs[curarg][t++]=str[i];
else
{
GameArgs[curarg][t]=0;
t=0;
mprintf(0,"Arg %d is %s\n",curarg,GameArgs[curarg]);
if (gotquote) {
if (str[i] != '\"' && str[i] != 0)
GameArgs[curarg][t++] = str[i];
else {
GameArgs[curarg][t] = 0;
t = 0;
mprintf(0, "Arg %d is %s\n", curarg, GameArgs[curarg]);
gotquote = false;
curarg++;
}
}
else
{
if (str[i]!=' ' && str[i]!=0)
GameArgs[curarg][t++]=str[i];
else
{
GameArgs[curarg][t]=0;
t=0;
mprintf(0,"Arg %d is %s\n",curarg,GameArgs[curarg]);
} else {
if (str[i] != ' ' && str[i] != 0)
GameArgs[curarg][t++] = str[i];
else {
GameArgs[curarg][t] = 0;
t = 0;
mprintf(0, "Arg %d is %s\n", curarg, GameArgs[curarg]);
curarg++;
}
}
}
GameArgs[curarg][t]=0;
GameArgs[curarg][t] = 0;
curarg++;
TotalArgs=curarg;
TotalArgs = curarg;
// clear out argument list.
for(;curarg < MAX_ARGS; curarg++)
// clear out argument list.
for (; curarg < MAX_ARGS; curarg++)
GameArgs[curarg][0] = 0;
}
// Returns index of argument sought, or 0 if not found
int FindArg (const char *which)
{
int FindArg(const char *which) {
int i;
for (i=1;i<=TotalArgs;i++)
if (stricmp (which,GameArgs[i])==0)
for (i = 1; i <= TotalArgs; i++)
if (stricmp(which, GameArgs[i]) == 0)
return (i);
return (0);
}
}

View File

@@ -33,7 +33,7 @@
#include "appdatabase.h"
int paged_in_num=0;
int paged_in_count=0;
class oeAppDatabase *Database=NULL;
int paged_in_num = 0;
int paged_in_count = 0;
class oeAppDatabase *Database = NULL;
bool Force_one_texture = false;

View File

@@ -1,26 +1,23 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// stdafx.cpp : source file that includes just the standard includes
// briefinglocalizer.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
@@ -37,7 +37,6 @@
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// briefinglocalizer.cpp : Defines the class behaviors for the application.
//
@@ -33,17 +33,15 @@ static char THIS_FILE[] = __FILE__;
// CBriefinglocalizerApp
BEGIN_MESSAGE_MAP(CBriefinglocalizerApp, CWinApp)
//{{AFX_MSG_MAP(CBriefinglocalizerApp)
//}}AFX_MSG
ON_COMMAND(ID_HELP, CWinApp::OnHelp)
//{{AFX_MSG_MAP(CBriefinglocalizerApp)
//}}AFX_MSG
ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBriefinglocalizerApp construction
CBriefinglocalizerApp::CBriefinglocalizerApp()
{
}
CBriefinglocalizerApp::CBriefinglocalizerApp() {}
/////////////////////////////////////////////////////////////////////////////
// The one and only CBriefinglocalizerApp object
@@ -53,13 +51,11 @@ CBriefinglocalizerApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CBriefinglocalizerApp initialization
BOOL CBriefinglocalizerApp::InitInstance()
{
BOOL CBriefinglocalizerApp::InitInstance() {
// Standard initialization
SetRegistryKey(_T("Descent 3 Briefing Localizer"));
AfxInitRichEdit( );
AfxInitRichEdit();
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
@@ -70,11 +66,8 @@ BOOL CBriefinglocalizerApp::InitInstance()
CBriefinglocalizerDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
}
else if (nResponse == IDCANCEL)
{
if (nResponse == IDOK) {
} else if (nResponse == IDCANCEL) {
}
// Since the dialog has been closed, return FALSE so that we exit the

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// briefinglocalizer.h : main header file for the BRIEFINGLOCALIZER application
//
@@ -27,7 +27,7 @@
#endif // _MSC_VER > 1000
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
@@ -37,26 +37,24 @@
// See briefinglocalizer.cpp for the implementation of this class
//
class CBriefinglocalizerApp : public CWinApp
{
class CBriefinglocalizerApp : public CWinApp {
public:
CBriefinglocalizerApp();
// Overrides
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CBriefinglocalizerApp)
public:
public:
virtual BOOL InitInstance();
//}}AFX_VIRTUAL
// Implementation
// Implementation
//{{AFX_MSG(CBriefinglocalizerApp)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// briefinglocalizerDlg.cpp : implementation file
//
@@ -32,7 +32,6 @@
#include <stdio.h>
#include <direct.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
@@ -48,18 +47,19 @@ static char THIS_FILE[] = __FILE__;
#define TEXT_SHOW_TAG "show"
#define TEXT_SHOW_TAG_LEN strlen(TEXT_SHOW_TAG)
#define TEXT_END_TAG "$endtext"
#define TEXT_END_TAG_TAG_LEN strlen(TEXT_END_TAG)
#define FIND_NEXT_LINE(a,b) do{ while( ((b[a]==0x0a) || (b[a]==0x0d)) && (a<(b).GetLength()) ) a++; }while(0)
//a = (b).FindOneOf("\x0a\x0d"); if(a!=-1)
#define FIND_NEXT_LINE(a, b) \
do { \
while (((b[a] == 0x0a) || (b[a] == 0x0d)) && (a < (b).GetLength())) \
a++; \
} while (0)
// a = (b).FindOneOf("\x0a\x0d"); if(a!=-1)
/////////////////////////////////////////////////////////////////////////////
// CBriefinglocalizerDlg dialog
CBriefinglocalizerDlg::CBriefinglocalizerDlg(CWnd* pParent /*=NULL*/)
: CDialog(CBriefinglocalizerDlg::IDD, pParent)
{
CBriefinglocalizerDlg::CBriefinglocalizerDlg(CWnd *pParent /*=NULL*/) : CDialog(CBriefinglocalizerDlg::IDD, pParent) {
//{{AFX_DATA_INIT(CBriefinglocalizerDlg)
m_Title = _T("");
m_Text = _T("");
@@ -72,8 +72,7 @@ CBriefinglocalizerDlg::CBriefinglocalizerDlg(CWnd* pParent /*=NULL*/)
m_BigTextString.Empty();
}
void CBriefinglocalizerDlg::DoDataExchange(CDataExchange* pDX)
{
void CBriefinglocalizerDlg::DoDataExchange(CDataExchange *pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CBriefinglocalizerDlg)
DDX_Control(pDX, IDC_TEXT, m_RichText);
@@ -83,36 +82,34 @@ void CBriefinglocalizerDlg::DoDataExchange(CDataExchange* pDX)
}
BEGIN_MESSAGE_MAP(CBriefinglocalizerDlg, CDialog)
//{{AFX_MSG_MAP(CBriefinglocalizerDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_NEXT, OnNext)
ON_BN_CLICKED(IDC_PREV, OnPrev)
ON_BN_CLICKED(IDC_QUIT, OnQuit)
ON_BN_CLICKED(IDC_SAVE, OnSave)
ON_EN_KILLFOCUS(IDC_TITLE, OnKillfocusTitle)
ON_EN_CHANGE(IDC_TEXT, OnChangeText)
ON_EN_CHANGE(IDC_TITLE, OnChangeTitle)
ON_NOTIFY(NM_KILLFOCUS, IDC_TEXT, OnKillfocusText)
ON_NOTIFY(EN_KILLFOCUS, IDC_TEXT, OnKillfocusText)
//}}AFX_MSG_MAP
//{{AFX_MSG_MAP(CBriefinglocalizerDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_NEXT, OnNext)
ON_BN_CLICKED(IDC_PREV, OnPrev)
ON_BN_CLICKED(IDC_QUIT, OnQuit)
ON_BN_CLICKED(IDC_SAVE, OnSave)
ON_EN_KILLFOCUS(IDC_TITLE, OnKillfocusTitle)
ON_EN_CHANGE(IDC_TEXT, OnChangeText)
ON_EN_CHANGE(IDC_TITLE, OnChangeTitle)
ON_NOTIFY(NM_KILLFOCUS, IDC_TEXT, OnKillfocusText)
ON_NOTIFY(EN_KILLFOCUS, IDC_TEXT, OnKillfocusText)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBriefinglocalizerDlg message handlers
BOOL CBriefinglocalizerDlg::OnInitDialog()
{
static char sztemppath[_MAX_PATH*2] = ".";
static char sztempfile[_MAX_PATH*2] = "tempfile.tmp";
char path[_MAX_PATH*2];
BOOL CBriefinglocalizerDlg::OnInitDialog() {
static char sztemppath[_MAX_PATH * 2] = ".";
static char sztempfile[_MAX_PATH * 2] = "tempfile.tmp";
char path[_MAX_PATH * 2];
char drive[10];
CString savepath;
CString DefaultPath;
CDialog::OnInitDialog();
m_RichText.SetEventMask(ENM_CHANGE);
SetIcon(m_hIcon, TRUE); // Set big icon
@@ -120,33 +117,30 @@ BOOL CBriefinglocalizerDlg::OnInitDialog()
CFileDialog *fd;
DefaultPath = AfxGetApp()->GetProfileString("Defaults","LastDir","");
DefaultPath = AfxGetApp()->GetProfileString("Defaults", "LastDir", "");
static char szFilter[] = "Descent 3 Briefing (*.br?)|*.br?|All Files (*.*)|*.*||";
_chdir(DefaultPath);
fd = new CFileDialog(true,".brf",NULL,OFN_FILEMUSTEXIST|OFN_HIDEREADONLY,szFilter);
if (fd->DoModal() == IDCANCEL)
{
fd = new CFileDialog(true, ".brf", NULL, OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, szFilter);
if (fd->DoModal() == IDCANCEL) {
delete fd;
CDialog::OnCancel();
return FALSE;
}
GetTempPath(_MAX_PATH*2,sztemppath);
GetTempPath(_MAX_PATH * 2, sztemppath);
m_RealFileName = fd->GetPathName();
_splitpath(m_RealFileName,drive,path,NULL,NULL);
_splitpath(m_RealFileName, drive, path, NULL, NULL);
savepath = drive;
savepath += path;
AfxGetApp()->WriteProfileString("Defaults","LastDir",savepath);
AfxGetApp()->WriteProfileString("Defaults", "LastDir", savepath);
GetTempFileName(sztemppath,"d3brf",0x42,sztempfile);
GetTempFileName(sztemppath, "d3brf", 0x42, sztempfile);
m_TempFileName = sztempfile;
@@ -154,23 +148,21 @@ BOOL CBriefinglocalizerDlg::OnInitDialog()
fd = NULL;
FILE *infile;
struct _stat buf;
int result = _stat( m_RealFileName, &buf );
if(result!=0)
{
AfxMessageBox("Error: Cannot determine file size!",MB_OK|MB_ICONSTOP);
int result = _stat(m_RealFileName, &buf);
if (result != 0) {
AfxMessageBox("Error: Cannot determine file size!", MB_OK | MB_ICONSTOP);
goto do_error;
}
infile = fopen(m_RealFileName,"rt");
if(infile)
{
infile = fopen(m_RealFileName, "rt");
if (infile) {
CString newtitle;
newtitle.Format("Outrage Briefing file localizer -- %s",m_RealFileName);
newtitle.Format("Outrage Briefing file localizer -- %s", m_RealFileName);
SetWindowText(newtitle);
char *szbuf;
szbuf = (char *)malloc(buf.st_size);
fread(szbuf,buf.st_size,1,infile);
fread(szbuf, buf.st_size, 1, infile);
fclose(infile);
m_BigTextString = szbuf;
m_BigStringTextLower = m_BigTextString;
@@ -180,34 +172,26 @@ BOOL CBriefinglocalizerDlg::OnInitDialog()
delete szbuf;
m_TitleLeft = m_BigStringTextLower.Find(TITLE_TAG);
if(m_TitleLeft!=-1)
{
m_TitleRight = m_BigStringTextLower.Find("\"",m_TitleLeft+TITLE_TAG_LENGTH);
m_Title = m_BigTextString.Mid(TITLE_TAG_LENGTH+m_TitleLeft,(m_TitleRight-(m_TitleLeft+TITLE_TAG_LENGTH)));
}
else
{
AfxMessageBox("Warning: There is no title in this briefing file!",MB_OK);
if (m_TitleLeft != -1) {
m_TitleRight = m_BigStringTextLower.Find("\"", m_TitleLeft + TITLE_TAG_LENGTH);
m_Title = m_BigTextString.Mid(TITLE_TAG_LENGTH + m_TitleLeft, (m_TitleRight - (m_TitleLeft + TITLE_TAG_LENGTH)));
} else {
AfxMessageBox("Warning: There is no title in this briefing file!", MB_OK);
GetDlgItem(IDC_TITLE)->EnableWindow(false);
}
//Now I need to find the first text item!
// Now I need to find the first text item!
m_CurTextLeft = m_BigStringTextLower.Find(TEXT_START_TAG);
if(m_CurTextLeft!=-1)
{
m_CurTextLeft = m_BigStringTextLower.Find(TEXT_SHOW_TAG,m_CurTextLeft);
if(m_CurTextLeft!=-1)
{
m_CurTextRight = m_BigStringTextLower.Find(TEXT_END_TAG,m_CurTextLeft+TEXT_SHOW_TAG_LEN);
if (m_CurTextLeft != -1) {
m_CurTextLeft = m_BigStringTextLower.Find(TEXT_SHOW_TAG, m_CurTextLeft);
if (m_CurTextLeft != -1) {
m_CurTextRight = m_BigStringTextLower.Find(TEXT_END_TAG, m_CurTextLeft + TEXT_SHOW_TAG_LEN);
m_CurTextLeft += TEXT_SHOW_TAG_LEN;
FIND_NEXT_LINE(m_CurTextLeft,m_BigTextString);
m_Text = m_BigTextString.Mid(m_CurTextLeft,(m_CurTextRight-(m_CurTextLeft)-1));
FIND_NEXT_LINE(m_CurTextLeft, m_BigTextString);
m_Text = m_BigTextString.Mid(m_CurTextLeft, (m_CurTextRight - (m_CurTextLeft)-1));
}
}
else
{
AfxMessageBox("Warning: There is no text in this briefing file!",MB_OK);
} else {
AfxMessageBox("Warning: There is no text in this briefing file!", MB_OK);
GetDlgItem(IDC_NEXT)->EnableWindow(false);
GetDlgItem(IDC_PREV)->EnableWindow(false);
GetDlgItem(IDC_TEXT)->EnableWindow(false);
@@ -215,33 +199,29 @@ BOOL CBriefinglocalizerDlg::OnInitDialog()
m_CurrentText = 1;
//Disable the previous button
// Disable the previous button
GetDlgItem(IDC_PREV)->EnableWindow(false);
UpdateData(false);
return TRUE; // return TRUE unless you set the focus to a control
}
do_error:
AfxMessageBox("Error: Cannot open specified file!",MB_OK|MB_ICONSTOP);
AfxMessageBox("Error: Cannot open specified file!", MB_OK | MB_ICONSTOP);
CDialog::OnCancel();
return TRUE;
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CBriefinglocalizerDlg::OnPaint()
{
if (IsIconic())
{
void CBriefinglocalizerDlg::OnPaint() {
if (IsIconic()) {
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
SendMessage(WM_ICONERASEBKGND, (WPARAM)dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
@@ -253,118 +233,97 @@ void CBriefinglocalizerDlg::OnPaint()
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
} else {
CDialog::OnPaint();
}
}
HCURSOR CBriefinglocalizerDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
HCURSOR CBriefinglocalizerDlg::OnQueryDragIcon() { return (HCURSOR)m_hIcon; }
void CBriefinglocalizerDlg::OnNext()
{
//Get the text out of the dialog...
void CBriefinglocalizerDlg::OnNext() {
// Get the text out of the dialog...
UpdateData(true);
CString left,right;
CString left, right;
left = m_BigTextString.Left(m_CurTextLeft);
right = m_BigTextString.Right(m_BigTextString.GetLength()-m_CurTextRight);
right = m_BigTextString.Right(m_BigTextString.GetLength() - m_CurTextRight);
m_BigTextString = left + m_Text + "\n" + right;
m_BigStringTextLower = m_BigTextString;
m_BigStringTextLower.MakeLower();
m_CurTextRight = m_CurTextLeft + m_Text.GetLength();
int saveleft = m_CurTextLeft;
//Now I need to find the next text item!
m_CurTextLeft = m_BigStringTextLower.Find(TEXT_START_TAG,m_CurTextRight);
if(m_CurTextLeft!=-1)
{
m_CurTextLeft = m_BigStringTextLower.Find(TEXT_SHOW_TAG,m_CurTextLeft);
if(m_CurTextLeft!=-1)
{
m_CurTextRight = m_BigStringTextLower.Find(TEXT_END_TAG,m_CurTextLeft+TEXT_SHOW_TAG_LEN);
// Now I need to find the next text item!
m_CurTextLeft = m_BigStringTextLower.Find(TEXT_START_TAG, m_CurTextRight);
if (m_CurTextLeft != -1) {
m_CurTextLeft = m_BigStringTextLower.Find(TEXT_SHOW_TAG, m_CurTextLeft);
if (m_CurTextLeft != -1) {
m_CurTextRight = m_BigStringTextLower.Find(TEXT_END_TAG, m_CurTextLeft + TEXT_SHOW_TAG_LEN);
m_CurTextLeft += TEXT_SHOW_TAG_LEN;
FIND_NEXT_LINE(m_CurTextLeft,m_BigTextString);
m_Text = m_BigTextString.Mid(m_CurTextLeft,(m_CurTextRight-(m_CurTextLeft)-1));
FIND_NEXT_LINE(m_CurTextLeft, m_BigTextString);
m_Text = m_BigTextString.Mid(m_CurTextLeft, (m_CurTextRight - (m_CurTextLeft)-1));
GetDlgItem(IDC_PREV)->EnableWindow(true);
m_CurrentText++;
}
}
else
{
} else {
m_CurTextLeft = saveleft;
GetDlgItem(IDC_NEXT)->EnableWindow(false);
}
UpdateData(false);
}
void CBriefinglocalizerDlg::OnPrev()
{
void CBriefinglocalizerDlg::OnPrev() {
UpdateData(true);
CString left,right;
CString left, right;
left = m_BigTextString.Left(m_CurTextLeft);
right = m_BigTextString.Right(m_BigTextString.GetLength()-m_CurTextRight);
right = m_BigTextString.Right(m_BigTextString.GetLength() - m_CurTextRight);
m_BigTextString = left + m_Text + "\n" + right;
m_BigStringTextLower = m_BigTextString;
m_BigStringTextLower.MakeLower();
m_CurTextRight = 0;
m_CurTextLeft = 0;
m_CurrentText--;
int count = 0;
//Rewind to the previous item
while(count!=m_CurrentText)
{
m_CurTextLeft = m_BigStringTextLower.Find(TEXT_START_TAG,m_CurTextRight);
if(m_CurTextLeft!=-1)
{
m_CurTextLeft = m_BigStringTextLower.Find(TEXT_SHOW_TAG,m_CurTextLeft);
if(m_CurTextLeft!=-1)
{
m_CurTextRight = m_BigStringTextLower.Find(TEXT_END_TAG,m_CurTextLeft+TEXT_SHOW_TAG_LEN);
// Rewind to the previous item
while (count != m_CurrentText) {
m_CurTextLeft = m_BigStringTextLower.Find(TEXT_START_TAG, m_CurTextRight);
if (m_CurTextLeft != -1) {
m_CurTextLeft = m_BigStringTextLower.Find(TEXT_SHOW_TAG, m_CurTextLeft);
if (m_CurTextLeft != -1) {
m_CurTextRight = m_BigStringTextLower.Find(TEXT_END_TAG, m_CurTextLeft + TEXT_SHOW_TAG_LEN);
m_CurTextLeft += TEXT_SHOW_TAG_LEN;
FIND_NEXT_LINE(m_CurTextLeft,m_BigTextString);
FIND_NEXT_LINE(m_CurTextLeft, m_BigTextString);
}
}
count++;
}
m_Text = m_BigTextString.Mid(m_CurTextLeft,(m_CurTextRight-(m_CurTextLeft)));
m_Text = m_BigTextString.Mid(m_CurTextLeft, (m_CurTextRight - (m_CurTextLeft)));
GetDlgItem(IDC_NEXT)->EnableWindow(true);
if(m_CurrentText<=1)
{
//Disable the previous button
if (m_CurrentText <= 1) {
// Disable the previous button
GetDlgItem(IDC_PREV)->EnableWindow(false);
}
UpdateData(false);
}
void CBriefinglocalizerDlg::OnQuit()
{
//See if the file has changed since it was last saved
if(m_FileChanged)
{
int res = AfxMessageBox("Briefing has changed, would you like to save your changes?",MB_YESNOCANCEL);
switch(res)
{
void CBriefinglocalizerDlg::OnQuit() {
// See if the file has changed since it was last saved
if (m_FileChanged) {
int res = AfxMessageBox("Briefing has changed, would you like to save your changes?", MB_YESNOCANCEL);
switch (res) {
case IDYES:
//Prompt to save if it has
// Prompt to save if it has
OnSave();
break;
case IDNO:
@@ -376,91 +335,74 @@ void CBriefinglocalizerDlg::OnQuit()
}
}
CDialog::OnCancel();
}
void CBriefinglocalizerDlg::OnSave()
{
//Update the big string
void CBriefinglocalizerDlg::OnSave() {
// Update the big string
CString testfile;
FILE *outfile;
testfile = m_RealFileName;// + ".test";
outfile = fopen(testfile,"wt");
if(outfile)
{
fwrite(LPCSTR(m_BigTextString),m_BigTextString.GetLength(),1,outfile);
testfile = m_RealFileName; // + ".test";
outfile = fopen(testfile, "wt");
if (outfile) {
fwrite(LPCSTR(m_BigTextString), m_BigTextString.GetLength(), 1, outfile);
m_FileChanged = false;
fclose(outfile);
} else {
AfxMessageBox("Error: Unable to write to file!", MB_OK);
}
else
{
AfxMessageBox("Error: Unable to write to file!",MB_OK);
}
}
void CBriefinglocalizerDlg::OnKillfocusTitle()
{
void CBriefinglocalizerDlg::OnKillfocusTitle() {
CString oldtitle = m_Title;
UpdateData(true);
int titlelendelta = m_Title.GetLength()-oldtitle.GetLength();
int titleleft=0;
int titleright=0;
CString left,right;
int titlelendelta = m_Title.GetLength() - oldtitle.GetLength();
int titleleft = 0;
int titleright = 0;
CString left, right;
titleleft = m_BigStringTextLower.Find(TITLE_TAG);
if(titleleft!=-1)
{
titleright = m_BigStringTextLower.Find("\"",titleleft+TITLE_TAG_LENGTH);
left = m_BigTextString.Left(titleleft+TITLE_TAG_LENGTH);
right = m_BigTextString.Right(m_BigTextString.GetLength()-(titleright+1));
m_BigTextString = left + m_Title + "\"" + right ;
if (titleleft != -1) {
titleright = m_BigStringTextLower.Find("\"", titleleft + TITLE_TAG_LENGTH);
left = m_BigTextString.Left(titleleft + TITLE_TAG_LENGTH);
right = m_BigTextString.Right(m_BigTextString.GetLength() - (titleright + 1));
m_BigTextString = left + m_Title + "\"" + right;
m_BigStringTextLower = m_BigTextString;
m_BigStringTextLower.MakeLower();
m_CurTextLeft += titlelendelta;
m_CurTextRight += titlelendelta;
}
}
void CBriefinglocalizerDlg::OnCancel()
{
//do nothing... we want to use OnQuit()
//CDialog::OnCancel();
void CBriefinglocalizerDlg::OnCancel() {
// do nothing... we want to use OnQuit()
// CDialog::OnCancel();
}
void CBriefinglocalizerDlg::OnChangeText()
{
void CBriefinglocalizerDlg::OnChangeText() {
m_FileChanged = true;
UpdateData(true);
CString left,right;
CString left, right;
left = m_BigTextString.Left(m_CurTextLeft);
right = m_BigTextString.Right(m_BigTextString.GetLength()-m_CurTextRight);
right = m_BigTextString.Right(m_BigTextString.GetLength() - m_CurTextRight);
m_BigTextString = left + m_Text + "\n" + right;
m_BigStringTextLower = m_BigTextString;
m_BigStringTextLower.MakeLower();
m_CurTextRight = m_CurTextLeft + m_Text.GetLength();
}
void CBriefinglocalizerDlg::OnChangeTitle()
{
m_FileChanged = true;
}
void CBriefinglocalizerDlg::OnChangeTitle() { m_FileChanged = true; }
void CBriefinglocalizerDlg::OnKillfocusText(NMHDR* pNMHDR, LRESULT* pResult)
{
void CBriefinglocalizerDlg::OnKillfocusText(NMHDR *pNMHDR, LRESULT *pResult) {
UpdateData(true);
CString left,right;
CString left, right;
left = m_BigTextString.Left(m_CurTextLeft);
right = m_BigTextString.Right(m_BigTextString.GetLength()-m_CurTextRight);
right = m_BigTextString.Right(m_BigTextString.GetLength() - m_CurTextRight);
m_BigTextString = left + m_Text + "\n" + right;
m_BigStringTextLower = m_BigTextString;

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// briefinglocalizerDlg.h : header file
//
@@ -29,9 +29,8 @@
/////////////////////////////////////////////////////////////////////////////
// CBriefinglocalizerDlg dialog
class CBriefinglocalizerDlg : public CDialog
{
// Construction
class CBriefinglocalizerDlg : public CDialog {
// Construction
public:
int m_TitleRight;
int m_TitleLeft;
@@ -43,9 +42,9 @@ public:
CString m_TempFileName;
CString m_RealFileName;
bool m_FileChanged;
CBriefinglocalizerDlg(CWnd* pParent = NULL); // standard constructor
CBriefinglocalizerDlg(CWnd *pParent = NULL); // standard constructor
// Dialog Data
// Dialog Data
//{{AFX_DATA(CBriefinglocalizerDlg)
enum { IDD = IDD_BRIEFINGLOCALIZER_DIALOG };
CRichEditCtrl m_RichText;
@@ -55,11 +54,11 @@ public:
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CBriefinglocalizerDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
protected:
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
// Implementation
protected:
HICON m_hIcon;
@@ -76,7 +75,7 @@ protected:
virtual void OnCancel();
afx_msg void OnChangeText();
afx_msg void OnChangeTitle();
afx_msg void OnKillfocusText(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnKillfocusText(NMHDR *pNMHDR, LRESULT *pResult);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
///////////////////////////////////////////////////////////////////////////
// DirDialog.cpp: implementation of the CDirDialog class.
@@ -26,34 +26,30 @@
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
static char THIS_FILE[] = __FILE__;
#define new DEBUG_NEW
#endif
// Callback function called by SHBrowseForFolder's browse control
// after initialization and when selection changes
int __stdcall CDirDialog::BrowseCtrlCallback(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
{
CDirDialog* pDirDialogObj = (CDirDialog*)lpData;
if (uMsg == BFFM_INITIALIZED )
{
if( ! pDirDialogObj->m_strSelDir.IsEmpty() )
int __stdcall CDirDialog::BrowseCtrlCallback(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData) {
CDirDialog *pDirDialogObj = (CDirDialog *)lpData;
if (uMsg == BFFM_INITIALIZED) {
if (!pDirDialogObj->m_strSelDir.IsEmpty())
::SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)(LPCTSTR)(pDirDialogObj->m_strSelDir));
if( ! pDirDialogObj->m_strWindowTitle.IsEmpty() )
::SetWindowText(hwnd, (LPCTSTR) pDirDialogObj->m_strWindowTitle);
}
else if( uMsg == BFFM_SELCHANGED )
{
LPITEMIDLIST pidl = (LPITEMIDLIST) lParam;
if (!pDirDialogObj->m_strWindowTitle.IsEmpty())
::SetWindowText(hwnd, (LPCTSTR)pDirDialogObj->m_strWindowTitle);
} else if (uMsg == BFFM_SELCHANGED) {
LPITEMIDLIST pidl = (LPITEMIDLIST)lParam;
char selection[_MAX_PATH];
if( ! ::SHGetPathFromIDList(pidl, selection) )
if (!::SHGetPathFromIDList(pidl, selection))
selection[0] = '\0';
CString csStatusText;
BOOL bOk = pDirDialogObj->SelChanged(selection, csStatusText);
if( pDirDialogObj->m_bStatus )
::SendMessage(hwnd, BFFM_SETSTATUSTEXT , 0, (LPARAM)(LPCSTR)csStatusText);
if (pDirDialogObj->m_bStatus)
::SendMessage(hwnd, BFFM_SETSTATUSTEXT, 0, (LPARAM)(LPCSTR)csStatusText);
::SendMessage(hwnd, BFFM_ENABLEOK, 0, bOk);
}
@@ -64,35 +60,27 @@ int __stdcall CDirDialog::BrowseCtrlCallback(HWND hwnd, UINT uMsg, LPARAM lParam
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CDirDialog::CDirDialog()
{
m_bStatus = FALSE;
}
CDirDialog::CDirDialog() { m_bStatus = FALSE; }
CDirDialog::~CDirDialog()
{
}
CDirDialog::~CDirDialog() {}
BOOL CDirDialog::DoBrowse(CWnd *pwndParent)
{
BOOL CDirDialog::DoBrowse(CWnd *pwndParent) {
if( ! m_strSelDir.IsEmpty() )
{
if (!m_strSelDir.IsEmpty()) {
m_strSelDir.TrimRight();
if( m_strSelDir.Right(1) == "\\" || m_strSelDir.Right(1) == "//" )
if (m_strSelDir.Right(1) == "\\" || m_strSelDir.Right(1) == "//")
m_strSelDir = m_strSelDir.Left(m_strSelDir.GetLength() - 1);
}
LPMALLOC pMalloc;
if (SHGetMalloc (&pMalloc)!= NOERROR)
if (SHGetMalloc(&pMalloc) != NOERROR)
return FALSE;
BROWSEINFO bInfo;
LPITEMIDLIST pidl;
ZeroMemory ( (PVOID) &bInfo,sizeof (BROWSEINFO));
ZeroMemory((PVOID)&bInfo, sizeof(BROWSEINFO));
if (!m_strInitDir.IsEmpty ())
{
if (!m_strInitDir.IsEmpty()) {
OLECHAR olePath[_MAX_PATH];
ULONG chEaten;
ULONG dwAttributes;
@@ -101,62 +89,49 @@ BOOL CDirDialog::DoBrowse(CWnd *pwndParent)
//
// Get a pointer to the Desktop's IShellFolder interface.
//
if (SUCCEEDED(SHGetDesktopFolder(&pDesktopFolder)))
{
if (SUCCEEDED(SHGetDesktopFolder(&pDesktopFolder))) {
//
// IShellFolder::ParseDisplayName requires the file name be in Unicode.
//
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, m_strInitDir.GetBuffer(_MAX_PATH), -1,
olePath, _MAX_PATH);
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, m_strInitDir.GetBuffer(_MAX_PATH), -1, olePath, _MAX_PATH);
m_strInitDir.ReleaseBuffer (-1);
m_strInitDir.ReleaseBuffer(-1);
//
// Convert the path to an ITEMIDLIST.
//
hr = pDesktopFolder->ParseDisplayName(NULL,
NULL,
olePath,
&chEaten,
&pidl,
&dwAttributes);
if (FAILED(hr))
{
pMalloc ->Free (pidl);
pMalloc ->Release ();
hr = pDesktopFolder->ParseDisplayName(NULL, NULL, olePath, &chEaten, &pidl, &dwAttributes);
if (FAILED(hr)) {
pMalloc->Free(pidl);
pMalloc->Release();
return FALSE;
}
bInfo.pidlRoot = pidl;
}
}
bInfo.hwndOwner = pwndParent == NULL ? NULL : pwndParent->GetSafeHwnd();
bInfo.pszDisplayName = m_strPath.GetBuffer (_MAX_PATH);
bInfo.pszDisplayName = m_strPath.GetBuffer(_MAX_PATH);
bInfo.lpszTitle = (m_strTitle.IsEmpty()) ? "Open" : m_strTitle;
bInfo.ulFlags = BIF_RETURNFSANCESTORS
| BIF_RETURNONLYFSDIRS
| (m_bStatus ? BIF_STATUSTEXT : 0);
bInfo.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS | (m_bStatus ? BIF_STATUSTEXT : 0);
bInfo.lpfn = BrowseCtrlCallback; // address of callback function
bInfo.lParam = (LPARAM)this; // pass address of object to callback function
if ((pidl = ::SHBrowseForFolder(&bInfo)) == NULL)
{
if ((pidl = ::SHBrowseForFolder(&bInfo)) == NULL) {
return FALSE;
}
m_strPath.ReleaseBuffer();
m_iImageIndex = bInfo.iImage;
if (::SHGetPathFromIDList(pidl, m_strPath.GetBuffer(_MAX_PATH)) == FALSE)
{
pMalloc ->Free(pidl);
pMalloc ->Release();
if (::SHGetPathFromIDList(pidl, m_strPath.GetBuffer(_MAX_PATH)) == FALSE) {
pMalloc->Free(pidl);
pMalloc->Release();
return FALSE;
}
m_strPath.ReleaseBuffer();
pMalloc ->Free(pidl);
pMalloc ->Release();
pMalloc->Free(pidl);
pMalloc->Release();
return TRUE;
}

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
////////////////////////////////////////////////////////////////////////
// DirDialog.h: interface for the CDirDialog class.
@@ -27,10 +27,8 @@
#pragma once
#endif // _MSC_VER >= 1000
class CDirDialog
{
class CDirDialog {
public:
CDirDialog();
virtual ~CDirDialog();
@@ -45,10 +43,8 @@ public:
BOOL m_bStatus;
private:
virtual BOOL SelChanged(LPCSTR lpcsSelection, CString& csStatusText) { return TRUE; };
virtual BOOL SelChanged(LPCSTR lpcsSelection, CString &csStatusText) { return TRUE; };
static int __stdcall CDirDialog::BrowseCtrlCallback(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData);
};
#endif // !defined(AFX_DIRDIALOG_H__62FFAC92_1DEE_11D1_B87A_0060979CDF6D__INCLUDED_)

View File

@@ -100,24 +100,23 @@ int ParseAppCommandLine(char *cmdline, char **argv, int max_args);
// CHogEditApp
BEGIN_MESSAGE_MAP(CHogEditApp, CWinApp)
//{{AFX_MSG_MAP(CHogEditApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
//{{AFX_MSG_MAP(CHogEditApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CHogEditApp construction
CHogEditApp::CHogEditApp()
{
CHogEditApp::CHogEditApp() {
// TODO: add construction code here,
WaitCursor=NULL;
DoAutoProcess=FALSE;
WaitCursor = NULL;
DoAutoProcess = FALSE;
// Place all significant initialization in InitInstance
}
@@ -129,8 +128,7 @@ CHogEditApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CHogEditApp initialization
BOOL CHogEditApp::InitInstance()
{
BOOL CHogEditApp::InitInstance() {
int k;
AfxEnableControlContainer();
@@ -153,54 +151,49 @@ BOOL CHogEditApp::InitInstance()
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
// Allocate mem for cmd line args
for(k=0;k<MAX_CMDLINE_ARGS;k++)
app_argv[k]=new char[MAX_CMDLINE_ARG_SIZE+1];
for (k = 0; k < MAX_CMDLINE_ARGS; k++)
app_argv[k] = new char[MAX_CMDLINE_ARG_SIZE + 1];
// Get the command line arguments
app_argc=ParseAppCommandLine(m_lpCmdLine,app_argv,MAX_CMDLINE_ARGS);
app_argc = ParseAppCommandLine(m_lpCmdLine, app_argv, MAX_CMDLINE_ARGS);
// See if user wants to do auto-processing of hog
DoAutoProcess=FALSE;
if(app_argc==2) {
AutoRibFilename=app_argv[0];
AutoHogFilename=app_argv[1];
DoAutoProcess=TRUE;
DoAutoProcess = FALSE;
if (app_argc == 2) {
AutoRibFilename = app_argv[0];
AutoHogFilename = app_argv[1];
DoAutoProcess = TRUE;
/*
AfxMessageBox(AutoRibFilename);
AfxMessageBox(AutoHogFilename);
*/
}
UseCurrentHogFilename=FALSE;
UseCurrentHogFilename = FALSE;
OutputDebugString("Parsing command line...\n");
// Delete mem for cmd line args
for(k=0;k<MAX_CMDLINE_ARGS;k++)
for (k = 0; k < MAX_CMDLINE_ARGS; k++)
delete[] app_argv[k];
app_argc=0;
app_argc = 0;
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CHogEditDoc),
CSingleDocTemplate *pDocTemplate;
pDocTemplate = new CSingleDocTemplate(IDR_MAINFRAME, RUNTIME_CLASS(CHogEditDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CHogEditView));
AddDocTemplate(pDocTemplate);
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
//ParseCommandLine(cmdInfo);
// ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The one and only window has been initialized, so show and update it.
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
@@ -214,23 +207,22 @@ BOOL CHogEditApp::InitInstance()
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
class CAboutDlg : public CDialog {
public:
CAboutDlg();
// Dialog Data
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
protected:
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
// No message handlers
@@ -238,28 +230,25 @@ protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) {
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
void CAboutDlg::DoDataExchange(CDataExchange *pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// App command to run the dialog
void CHogEditApp::OnAppAbout()
{
void CHogEditApp::OnAppAbout() {
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
@@ -267,117 +256,110 @@ void CHogEditApp::OnAppAbout()
/////////////////////////////////////////////////////////////////////////////
// CHogEditApp commands
// Displays the "are you sure?" dialog
int ModifiedPrompt(CWnd *caller)
{
int ModifiedPrompt(CWnd *caller) {
// If current file has been modified, check with user first...
if(!DocModified) return(IDYES);
if(caller->MessageBox("Your current file will be lost. Proceed?",
"File Has Been Modified",
MB_YESNO)==IDYES) return(IDYES);
return(IDNO);
if (!DocModified)
return (IDYES);
if (caller->MessageBox("Your current file will be lost. Proceed?", "File Has Been Modified", MB_YESNO) == IDYES)
return (IDYES);
return (IDNO);
}
// Checks if there are any messages and translates and dispatches them
#define MAX_MESSAGES 25
void ProcessMessages(void)
{
void ProcessMessages(void) {
MSG msg;
int MsgCount;
for ( MsgCount = MAX_MESSAGES;
MsgCount && PeekMessage( &msg, NULL, 0, 0, PM_REMOVE );
MsgCount--) {
TranslateMessage( &msg );
DispatchMessage( &msg );
for (MsgCount = MAX_MESSAGES; MsgCount && PeekMessage(&msg, NULL, 0, 0, PM_REMOVE); MsgCount--) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
// Updates the total files indicator
void UpdateTotalFiles(int num_files)
{
void UpdateTotalFiles(int num_files) {
char msg[256];
sprintf(msg,"Total Files: %d", num_files);
MainStatusBar->SetPaneText(1,msg,TRUE);
sprintf(msg, "Total Files: %d", num_files);
MainStatusBar->SetPaneText(1, msg, TRUE);
ProcessMessages();
}
// Updates the status bar with the given message
CWaitCursor *WaitCursor;
void UpdateStatusBar(char *msg)
{
if(msg==NULL) return;
void UpdateStatusBar(char *msg) {
if (msg == NULL)
return;
MainStatusBar->SetPaneText(0,msg,TRUE);
MainStatusBar->SetPaneText(0, msg, TRUE);
ProcessMessages();
// If the WaitCursor is not null, restore it
if(WaitCursor!=NULL)
if (WaitCursor != NULL)
WaitCursor->Restore();
}
// Parses the given command line into a list of arguments
#define MAX_CMDLINE_SIZE 1024
int ParseAppCommandLine(char *cmdline, char **argv, int max_args)
{
int ParseAppCommandLine(char *cmdline, char **argv, int max_args) {
int i, argc, done;
char *s, *q;
char line[MAX_CMDLINE_SIZE+1];
char line[MAX_CMDLINE_SIZE + 1];
// make working copy of command line
strncpy(line,cmdline,MAX_CMDLINE_SIZE);
line[MAX_CMDLINE_SIZE]='\0';
strncpy(line, cmdline, MAX_CMDLINE_SIZE);
line[MAX_CMDLINE_SIZE] = '\0';
// Init arglist to empty
for(i=0;i<max_args;i++)
argv[i][0]='\0';
for (i = 0; i < max_args; i++)
argv[i][0] = '\0';
argc=0;
s=line;
done=FALSE;
argc = 0;
s = line;
done = FALSE;
// Get the arguments
while(!done && argc<max_args) {
while (!done && argc < max_args) {
// strip off leading whitespace
while(isspace(*s)) s++;
while (isspace(*s))
s++;
// if it's the end of the line, we're done
if(strlen(s)==0) {
done=TRUE;
if (strlen(s) == 0) {
done = TRUE;
continue;
}
// process the argument
if((*s)=='\"') { // handle quoted arguments
if ((*s) == '\"') { // handle quoted arguments
s++; // skip to char after quote
q=strchr(s,'\"'); // find ending quote
if(q==NULL) {
strcpy(argv[argc],s);
s+=strlen(argv[argc]);
q = strchr(s, '\"'); // find ending quote
if (q == NULL) {
strcpy(argv[argc], s);
s += strlen(argv[argc]);
} else {
(*q) = '\0';
strcpy(argv[argc], s);
s = q + 1;
}
else {
(*q)='\0';
strcpy(argv[argc],s);
s=q+1;
}
}
else { // handle whitespace delimited args
q=s;
while(!isspace(*q) && (*q)!='\0') q++;
if((*q)!='\0') {
(*q)='\0';
} else { // handle whitespace delimited args
q = s;
while (!isspace(*q) && (*q) != '\0')
q++;
if ((*q) != '\0') {
(*q) = '\0';
q++;
}
strcpy(argv[argc],s);
s=q;
strcpy(argv[argc], s);
s = q;
}
argc++;
}
return(argc);
return (argc);
}

View File

@@ -67,7 +67,7 @@
#endif // _MSC_VER >= 1000
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
@@ -94,19 +94,18 @@ extern bool UseCurrentHogFilename;
// See HogEdit.cpp for the implementation of this class
//
class CHogEditApp : public CWinApp
{
class CHogEditApp : public CWinApp {
public:
CHogEditApp();
// Overrides
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CHogEditApp)
public:
public:
virtual BOOL InitInstance();
//}}AFX_VIRTUAL
// Implementation
// Implementation
//{{AFX_MSG(CHogEditApp)
afx_msg void OnAppAbout();
@@ -116,7 +115,6 @@ public:
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}

File diff suppressed because it is too large Load Diff

View File

@@ -80,10 +80,9 @@
#define ADDFILE_STAT_ERROR 3
// the following structures are slightly modified versions of the CFILE hog structs
struct hog_library_entry
{
struct hog_library_entry {
char path[_MAX_PATH]; // location of data file (filename not included)
char name[PSFILENAME_LEN+1]; // just the filename
char name[PSFILENAME_LEN + 1]; // just the filename
unsigned length; // length of this file
int32_t timestamp; // time and date of file
int flags; // misc flags
@@ -91,35 +90,33 @@ struct hog_library_entry
};
// the hog library structure
struct hog_library
{
struct hog_library {
char filename[_MAX_PATH]; // full hog file path (including filename)
int flags; // misc flags for the hog file
int num_entries; // number of entries in the hog file
CList <hog_library_entry, hog_library_entry&> filelist;
CList<hog_library_entry, hog_library_entry &> filelist;
};
// Comparison function for sorting filenames
int compare( const void *arg1, const void *arg2 );
int compare(const void *arg1, const void *arg2);
// HogEdit Doc class
class CHogEditDoc : public CDocument
{
class CHogEditDoc : public CDocument {
protected: // create from serialization only
CHogEditDoc();
DECLARE_DYNCREATE(CHogEditDoc)
// Attributes
// Attributes
public:
CString m_DocumentName; // name of hog document
bool m_StaticHog; // is library a loaded hogfile or a lite hogfile(only names)
bool m_NoNameChosen; // Isn't set until user specifies name for a new file
hog_library Library; // stores the list of entries
// Operations
// Operations
public:
int LoadDocument(CString& name); // loads a hog or rib
int SaveDocument(CString& name); // saves a hog or rib
int LoadDocument(CString &name); // loads a hog or rib
int SaveDocument(CString &name); // saves a hog or rib
void NewDocument(); // creates a new document (entry list)
int LoadHog(const char *pathname); // loads a Hog file
@@ -141,39 +138,37 @@ public:
uint32_t CalcHogFileSize(void);
FILE *FindFileInHog(char *hog_fname,tHogFileEntry *table_entry);
FILE *FindFileInHog(char *hog_fname, tHogFileEntry *table_entry);
int CreateNewHogFromCurrentHog(char *src_hog_fname, char *target_hog_fname,
int nfiles, const char **filenames,
void(* UpdateFunction)(char *));
int CreateNewHogFromCurrentHog(char *src_hog_fname, char *target_hog_fname, int nfiles, const char **filenames,
void (*UpdateFunction)(char *));
// Overrides
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CHogEditDoc)
public:
public:
virtual BOOL OnNewDocument();
virtual void Serialize(CArchive& ar);
virtual void Serialize(CArchive &ar);
//}}AFX_VIRTUAL
// Implementation
// Implementation
public:
virtual ~CHogEditDoc();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
virtual void Dump(CDumpContext &dc) const;
#endif
protected:
// Generated message map functions
// Generated message map functions
protected:
//{{AFX_MSG(CHogEditDoc)
afx_msg void OnUpdateActionInsert(CCmdUI* pCmdUI);
afx_msg void OnUpdateActionCreate(CCmdUI* pCmdUI);
afx_msg void OnUpdateFileSave(CCmdUI* pCmdUI);
afx_msg void OnUpdateFileSaveAs(CCmdUI* pCmdUI);
afx_msg void OnUpdateActionUpdate(CCmdUI* pCmdUI);
afx_msg void OnUpdateActionImport(CCmdUI* pCmdUI);
afx_msg void OnUpdateActionInsert(CCmdUI *pCmdUI);
afx_msg void OnUpdateActionCreate(CCmdUI *pCmdUI);
afx_msg void OnUpdateFileSave(CCmdUI *pCmdUI);
afx_msg void OnUpdateFileSaveAs(CCmdUI *pCmdUI);
afx_msg void OnUpdateActionUpdate(CCmdUI *pCmdUI);
afx_msg void OnUpdateActionImport(CCmdUI *pCmdUI);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

File diff suppressed because it is too large Load Diff

View File

@@ -92,17 +92,16 @@
// The size of the buffer to hold the list of "to-be-added" filenames
#define MAX_FILENAME_BUFFER 120000
class CHogEditView : public CListViewEx
{
class CHogEditView : public CListViewEx {
protected: // create from serialization only
CHogEditView();
DECLARE_DYNCREATE(CHogEditView)
// Attributes
// Attributes
public:
CHogEditDoc* GetDocument();
CHogEditDoc *GetDocument();
// Operations
// Operations
public:
void SetColumnWidths(void);
void GetFileType(char *type, char *filename);
@@ -110,27 +109,27 @@ public:
void UpdateList(void);
void UpdateTitle(CString &path, bool mod_flag);
// Overrides
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CHogEditView)
public:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
public:
virtual void OnDraw(CDC *pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT &cs);
protected:
virtual void OnInitialUpdate(); // called first time after construct
//}}AFX_VIRTUAL
// Implementation
// Implementation
public:
virtual ~CHogEditView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
virtual void Dump(CDumpContext &dc) const;
#endif
protected:
// Generated message map functions
// Generated message map functions
protected:
//{{AFX_MSG(CHogEditView)
afx_msg void OnFileNew();
@@ -141,12 +140,12 @@ protected:
afx_msg void OnActionDelete();
afx_msg void OnActionCreate();
afx_msg void OnViewFullRow();
afx_msg void OnUpdateViewFullRow(CCmdUI* pCmdUI);
afx_msg void OnUpdateViewFullRow(CCmdUI *pCmdUI);
afx_msg void OnActionUpdate();
afx_msg void OnActionExtract();
afx_msg void OnUpdateActionDelete(CCmdUI* pCmdUI);
afx_msg void OnUpdateActionExtract(CCmdUI* pCmdUI);
afx_msg void OnColumnclick(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnUpdateActionDelete(CCmdUI *pCmdUI);
afx_msg void OnUpdateActionExtract(CCmdUI *pCmdUI);
afx_msg void OnColumnclick(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnActionImport();
afx_msg LONG OnStraightToFileOpen(UINT, LONG);
//}}AFX_MSG
@@ -157,10 +156,8 @@ protected:
// update dialog
#define WM_STRAIGHT_TO_FILE_OPEN (WM_USER + 10)
#ifndef _DEBUG // debug version in HogEditView.cpp
inline CHogEditDoc* CHogEditView::GetDocument()
{ return (CHogEditDoc*)m_pDocument; }
inline CHogEditDoc *CHogEditView::GetDocument() { return (CHogEditDoc *)m_pDocument; }
#endif
/////////////////////////////////////////////////////////////////////////////

View File

@@ -48,10 +48,7 @@ static char THIS_FILE[] = __FILE__;
/////////////////////////////////////////////////////////////////////////////
// CHogInfo dialog
CHogInfo::CHogInfo(CWnd* pParent /*=NULL*/)
: CDialog(CHogInfo::IDD, pParent)
{
CHogInfo::CHogInfo(CWnd *pParent /*=NULL*/) : CDialog(CHogInfo::IDD, pParent) {
//{{AFX_DATA_INIT(CHogInfo)
m_NumFiles = _T("");
m_Location = _T("");
@@ -60,9 +57,7 @@ CHogInfo::CHogInfo(CWnd* pParent /*=NULL*/)
//}}AFX_DATA_INIT
}
void CHogInfo::DoDataExchange(CDataExchange* pDX)
{
void CHogInfo::DoDataExchange(CDataExchange *pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CHogInfo)
DDX_Text(pDX, IDC_HOGINFO_FILES, m_NumFiles);
@@ -72,17 +67,15 @@ void CHogInfo::DoDataExchange(CDataExchange* pDX)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CHogInfo, CDialog)
//{{AFX_MSG_MAP(CHogInfo)
//}}AFX_MSG_MAP
//{{AFX_MSG_MAP(CHogInfo)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CHogInfo message handlers
BOOL CHogInfo::OnInitDialog()
{
BOOL CHogInfo::OnInitDialog() {
CDialog::OnInitDialog();
// TODO: Add extra initialization here

View File

@@ -44,13 +44,12 @@
/////////////////////////////////////////////////////////////////////////////
// CHogInfo dialog
class CHogInfo : public CDialog
{
// Construction
class CHogInfo : public CDialog {
// Construction
public:
CHogInfo(CWnd* pParent = NULL); // standard constructor
CHogInfo(CWnd *pParent = NULL); // standard constructor
// Dialog Data
// Dialog Data
//{{AFX_DATA(CHogInfo)
enum { IDD = IDD_HOGINFO };
CString m_NumFiles;
@@ -59,17 +58,15 @@ public:
CString m_SizeMB;
//}}AFX_DATA
// Overrides
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CHogInfo)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
protected:
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CHogInfo)
virtual BOOL OnInitDialog();

View File

@@ -58,68 +58,53 @@
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
ON_WM_CLOSE()
//}}AFX_MSG_MAP
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
ON_WM_CLOSE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
static UINT indicators[] =
{
ID_SEPARATOR, // status line indicator
//ID_INDICATOR_CAPS,
//ID_INDICATOR_NUM,
//ID_INDICATOR_SCRL,
ID_INDICATOR_FILES
};
static UINT indicators[] = {ID_SEPARATOR, // status line indicator
// ID_INDICATOR_CAPS,
// ID_INDICATOR_NUM,
// ID_INDICATOR_SCRL,
ID_INDICATOR_FILES};
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
CMainFrame::CMainFrame()
{
CMainFrame::CMainFrame() {
// TODO: add member initialization code here
}
CMainFrame::~CMainFrame()
{
}
CMainFrame::~CMainFrame() {}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) {
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndToolBar.Create(this) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
if (!m_wndToolBar.Create(this) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) {
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators) / sizeof(UINT))) {
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
// Get pointer to status bar so we can set it elsewhere
MainStatusBar=&m_wndStatusBar;
MainStatusBar->SetPaneText(1,"Total Files: 0",TRUE);
MainStatusBar = &m_wndStatusBar;
MainStatusBar->SetPaneText(1, "Total Files: 0", TRUE);
// TODO: Remove this if you don't want tool tips or a resizeable toolbar
m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
@@ -130,14 +115,13 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
return 0;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT &cs) {
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
cs.cx=MAIN_WINDOW_WIDTH;
cs.cy=MAIN_WINDOW_HEIGHT;
cs.lpszName=HOG_EDIT_TITLE;
cs.style=WS_OVERLAPPEDWINDOW;
cs.cx = MAIN_WINDOW_WIDTH;
cs.cy = MAIN_WINDOW_HEIGHT;
cs.lpszName = HOG_EDIT_TITLE;
cs.style = WS_OVERLAPPEDWINDOW;
return CFrameWnd::PreCreateWindow(cs);
}
@@ -146,25 +130,19 @@ BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
// CMainFrame diagnostics
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CFrameWnd::AssertValid();
}
void CMainFrame::AssertValid() const { CFrameWnd::AssertValid(); }
void CMainFrame::Dump(CDumpContext& dc) const
{
CFrameWnd::Dump(dc);
}
void CMainFrame::Dump(CDumpContext &dc) const { CFrameWnd::Dump(dc); }
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
void CMainFrame::OnClose()
{
void CMainFrame::OnClose() {
// TODO: Add your message handler code here and/or call default
if(ModifiedPrompt(this)==IDNO) return;
if (ModifiedPrompt(this) == IDNO)
return;
CFrameWnd::OnClose();
}

View File

@@ -59,38 +59,34 @@
#define MAIN_WINDOW_WIDTH 800
#define MAIN_WINDOW_HEIGHT 600
class CMainFrame : public CFrameWnd
{
class CMainFrame : public CFrameWnd {
protected: // create from serialization only
CMainFrame();
DECLARE_DYNCREATE(CMainFrame)
// Attributes
// Attributes
public:
// Operations
// Operations
public:
// Overrides
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMainFrame)
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual BOOL PreCreateWindow(CREATESTRUCT &cs);
//}}AFX_VIRTUAL
// Implementation
// Implementation
public:
virtual ~CMainFrame();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
virtual void Dump(CDumpContext &dc) const;
#endif
protected: // control bar embedded members
CStatusBar m_wndStatusBar;
CToolBar m_wndToolBar;
// Generated message map functions
// Generated message map functions
protected:
//{{AFX_MSG(CMainFrame)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.

View File

@@ -1,24 +1,23 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// stdafx.cpp : source file that includes just the standard includes
// HogEdit.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
@@ -38,7 +38,6 @@
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// ListVwEx.cpp : implementation of the CListViewEx class
//
@@ -43,23 +43,22 @@ static char THIS_FILE[] = __FILE__;
IMPLEMENT_DYNCREATE(CListViewEx, CListView)
BEGIN_MESSAGE_MAP(CListViewEx, CListView)
//{{AFX_MSG_MAP(CListViewEx)
ON_WM_SIZE()
ON_WM_PAINT()
ON_WM_SETFOCUS()
ON_WM_KILLFOCUS()
//}}AFX_MSG_MAP
ON_MESSAGE(LVM_SETIMAGELIST, OnSetImageList)
ON_MESSAGE(LVM_SETTEXTCOLOR, OnSetTextColor)
ON_MESSAGE(LVM_SETTEXTBKCOLOR, OnSetTextBkColor)
ON_MESSAGE(LVM_SETBKCOLOR, OnSetBkColor)
//{{AFX_MSG_MAP(CListViewEx)
ON_WM_SIZE()
ON_WM_PAINT()
ON_WM_SETFOCUS()
ON_WM_KILLFOCUS()
//}}AFX_MSG_MAP
ON_MESSAGE(LVM_SETIMAGELIST, OnSetImageList)
ON_MESSAGE(LVM_SETTEXTCOLOR, OnSetTextColor)
ON_MESSAGE(LVM_SETTEXTBKCOLOR, OnSetTextBkColor)
ON_MESSAGE(LVM_SETBKCOLOR, OnSetBkColor)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CListViewEx construction/destruction
CListViewEx::CListViewEx()
{
CListViewEx::CListViewEx() {
m_bFullRowSel = TRUE;
m_bClientWidthSel = TRUE;
@@ -71,22 +70,18 @@ CListViewEx::CListViewEx()
m_clrBkgnd = ::GetSysColor(COLOR_WINDOW);
}
CListViewEx::~CListViewEx()
{
}
CListViewEx::~CListViewEx() {}
BOOL CListViewEx::PreCreateWindow(CREATESTRUCT& cs)
{
BOOL CListViewEx::PreCreateWindow(CREATESTRUCT &cs) {
// default is report view and full row selection
cs.style &= ~LVS_TYPEMASK;
cs.style |= LVS_REPORT | LVS_OWNERDRAWFIXED;
m_bFullRowSel = TRUE;
return(CListView::PreCreateWindow(cs));
return (CListView::PreCreateWindow(cs));
}
BOOL CListViewEx::SetFullRowSel(BOOL bFullRowSel)
{
BOOL CListViewEx::SetFullRowSel(BOOL bFullRowSel) {
// no painting during change
LockWindowUpdate();
@@ -106,13 +101,10 @@ BOOL CListViewEx::SetFullRowSel(BOOL bFullRowSel)
// repaint changes
UnlockWindowUpdate();
return(bRet);
return (bRet);
}
BOOL CListViewEx::GetFullRowSel()
{
return(m_bFullRowSel);
}
BOOL CListViewEx::GetFullRowSel() { return (m_bFullRowSel); }
/////////////////////////////////////////////////////////////////////////////
// CListViewEx drawing
@@ -121,13 +113,12 @@ BOOL CListViewEx::GetFullRowSel()
#define OFFSET_FIRST 2
#define OFFSET_OTHER 6
void CListViewEx::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
CListCtrl& ListCtrl=GetListCtrl();
CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
void CListViewEx::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) {
CListCtrl &ListCtrl = GetListCtrl();
CDC *pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
CRect rcItem(lpDrawItemStruct->rcItem);
UINT uiFlags = ILD_TRANSPARENT;
CImageList* pImageList;
CImageList *pImageList;
int nItem = lpDrawItemStruct->itemID;
BOOL bFocus = (GetFocus() == this);
COLORREF clrTextSave, clrBkSave;
@@ -135,7 +126,7 @@ void CListViewEx::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
static _TCHAR szBuff[_MAX_PATH];
LPCTSTR pszText;
// get item data
// get item data
LV_ITEM lvi;
lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE;
@@ -149,7 +140,7 @@ void CListViewEx::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
BOOL bSelected = (bFocus || (GetStyle() & LVS_SHOWSELALWAYS)) && lvi.state & LVIS_SELECTED;
bSelected = bSelected || (lvi.state & LVIS_DROPHILITED);
// set colors if item is selected
// set colors if item is selected
CRect rcAllLabels;
ListCtrl.GetItemRect(nItem, rcAllLabels, LVIR_BOUNDS);
@@ -158,101 +149,84 @@ void CListViewEx::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
ListCtrl.GetItemRect(nItem, rcLabel, LVIR_LABEL);
rcAllLabels.left = rcLabel.left;
if (m_bClientWidthSel && rcAllLabels.right<m_cxClient)
if (m_bClientWidthSel && rcAllLabels.right < m_cxClient)
rcAllLabels.right = m_cxClient;
if (bSelected)
{
if (bSelected) {
clrTextSave = pDC->SetTextColor(::GetSysColor(COLOR_HIGHLIGHTTEXT));
clrBkSave = pDC->SetBkColor(::GetSysColor(COLOR_HIGHLIGHT));
pDC->FillRect(rcAllLabels, &CBrush(::GetSysColor(COLOR_HIGHLIGHT)));
}
else
} else
pDC->FillRect(rcAllLabels, &CBrush(m_clrTextBk));
// set color and mask for the icon
// set color and mask for the icon
if (lvi.state & LVIS_CUT)
{
if (lvi.state & LVIS_CUT) {
clrImage = m_clrBkgnd;
uiFlags |= ILD_BLEND50;
}
else if (bSelected)
{
} else if (bSelected) {
clrImage = ::GetSysColor(COLOR_HIGHLIGHT);
uiFlags |= ILD_BLEND50;
}
// draw state icon
// draw state icon
UINT nStateImageMask = lvi.state & LVIS_STATEIMAGEMASK;
if (nStateImageMask)
{
int nImage = (nStateImageMask>>12) - 1;
if (nStateImageMask) {
int nImage = (nStateImageMask >> 12) - 1;
pImageList = ListCtrl.GetImageList(LVSIL_STATE);
if (pImageList)
{
pImageList->Draw(pDC, nImage,
CPoint(rcItem.left, rcItem.top), ILD_TRANSPARENT);
if (pImageList) {
pImageList->Draw(pDC, nImage, CPoint(rcItem.left, rcItem.top), ILD_TRANSPARENT);
}
}
// draw normal and overlay icon
// draw normal and overlay icon
CRect rcIcon;
ListCtrl.GetItemRect(nItem, rcIcon, LVIR_ICON);
pImageList = ListCtrl.GetImageList(LVSIL_SMALL);
if (pImageList)
{
UINT nOvlImageMask=lvi.state & LVIS_OVERLAYMASK;
if (rcItem.left<rcItem.right-1)
{
ImageList_DrawEx(pImageList->m_hImageList, lvi.iImage,
pDC->m_hDC,rcIcon.left,rcIcon.top, 16, 16,
m_clrBkgnd, clrImage, uiFlags | nOvlImageMask);
if (pImageList) {
UINT nOvlImageMask = lvi.state & LVIS_OVERLAYMASK;
if (rcItem.left < rcItem.right - 1) {
ImageList_DrawEx(pImageList->m_hImageList, lvi.iImage, pDC->m_hDC, rcIcon.left, rcIcon.top, 16, 16, m_clrBkgnd,
clrImage, uiFlags | nOvlImageMask);
}
}
// draw item label
// draw item label
ListCtrl.GetItemRect(nItem, rcItem, LVIR_LABEL);
rcItem.right -= m_cxStateImageOffset;
pszText = MakeShortString(pDC, szBuff,
rcItem.right-rcItem.left, 2*OFFSET_FIRST);
pszText = MakeShortString(pDC, szBuff, rcItem.right - rcItem.left, 2 * OFFSET_FIRST);
rcLabel = rcItem;
rcLabel.left += OFFSET_FIRST;
rcLabel.right -= OFFSET_FIRST;
pDC->DrawText(pszText,-1,rcLabel,DT_LEFT | DT_SINGLELINE | DT_NOPREFIX | DT_NOCLIP | DT_VCENTER);
pDC->DrawText(pszText, -1, rcLabel, DT_LEFT | DT_SINGLELINE | DT_NOPREFIX | DT_NOCLIP | DT_VCENTER);
// draw labels for extra columns
// draw labels for extra columns
LV_COLUMN lvc;
lvc.mask = LVCF_FMT | LVCF_WIDTH;
for(int nColumn = 1; ListCtrl.GetColumn(nColumn, &lvc); nColumn++)
{
for (int nColumn = 1; ListCtrl.GetColumn(nColumn, &lvc); nColumn++) {
rcItem.left = rcItem.right;
rcItem.right += lvc.cx;
int nRetLen = ListCtrl.GetItemText(nItem, nColumn,
szBuff, sizeof(szBuff));
int nRetLen = ListCtrl.GetItemText(nItem, nColumn, szBuff, sizeof(szBuff));
if (nRetLen == 0)
continue;
pszText = MakeShortString(pDC, szBuff,
rcItem.right - rcItem.left, 2*OFFSET_OTHER);
pszText = MakeShortString(pDC, szBuff, rcItem.right - rcItem.left, 2 * OFFSET_OTHER);
UINT nJustify = DT_LEFT;
if(pszText == szBuff)
{
switch(lvc.fmt & LVCFMT_JUSTIFYMASK)
{
if (pszText == szBuff) {
switch (lvc.fmt & LVCFMT_JUSTIFYMASK) {
case LVCFMT_RIGHT:
nJustify = DT_RIGHT;
break;
@@ -268,66 +242,56 @@ void CListViewEx::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
rcLabel.left += OFFSET_OTHER;
rcLabel.right -= OFFSET_OTHER;
pDC->DrawText(pszText, -1, rcLabel,
nJustify | DT_SINGLELINE | DT_NOPREFIX | DT_NOCLIP | DT_VCENTER);
pDC->DrawText(pszText, -1, rcLabel, nJustify | DT_SINGLELINE | DT_NOPREFIX | DT_NOCLIP | DT_VCENTER);
}
// draw focus rectangle if item has focus
// draw focus rectangle if item has focus
if (lvi.state & LVIS_FOCUSED && bFocus)
pDC->DrawFocusRect(rcAllLabels);
// set original colors if item was selected
// set original colors if item was selected
if (bSelected)
{
if (bSelected) {
pDC->SetTextColor(clrTextSave);
pDC->SetBkColor(clrBkSave);
}
}
LPCTSTR CListViewEx::MakeShortString(CDC* pDC, LPCTSTR lpszLong, int nColumnLen, int nOffset)
{
LPCTSTR CListViewEx::MakeShortString(CDC *pDC, LPCTSTR lpszLong, int nColumnLen, int nOffset) {
static const _TCHAR szThreeDots[] = _T("...");
int nStringLen = lstrlen(lpszLong);
if(nStringLen == 0 ||
(pDC->GetTextExtent(lpszLong, nStringLen).cx + nOffset) <= nColumnLen)
{
return(lpszLong);
if (nStringLen == 0 || (pDC->GetTextExtent(lpszLong, nStringLen).cx + nOffset) <= nColumnLen) {
return (lpszLong);
}
static _TCHAR szShort[_MAX_PATH];
lstrcpy(szShort,lpszLong);
int nAddLen = pDC->GetTextExtent(szThreeDots,sizeof(szThreeDots)).cx;
lstrcpy(szShort, lpszLong);
int nAddLen = pDC->GetTextExtent(szThreeDots, sizeof(szThreeDots)).cx;
for(int i = nStringLen-1; i > 0; i--)
{
for (int i = nStringLen - 1; i > 0; i--) {
szShort[i] = 0;
if((pDC->GetTextExtent(szShort, i).cx + nOffset + nAddLen)
<= nColumnLen)
{
if ((pDC->GetTextExtent(szShort, i).cx + nOffset + nAddLen) <= nColumnLen) {
break;
}
}
lstrcat(szShort, szThreeDots);
return(szShort);
return (szShort);
}
void CListViewEx::RepaintSelectedItems()
{
CListCtrl& ListCtrl = GetListCtrl();
void CListViewEx::RepaintSelectedItems() {
CListCtrl &ListCtrl = GetListCtrl();
CRect rcItem, rcLabel;
// invalidate focused item so it can repaint properly
// invalidate focused item so it can repaint properly
int nItem = ListCtrl.GetNextItem(-1, LVNI_FOCUSED);
if(nItem != -1)
{
if (nItem != -1) {
ListCtrl.GetItemRect(nItem, rcItem, LVIR_BOUNDS);
ListCtrl.GetItemRect(nItem, rcLabel, LVIR_LABEL);
rcItem.left = rcLabel.left;
@@ -335,13 +299,11 @@ void CListViewEx::RepaintSelectedItems()
InvalidateRect(rcItem, FALSE);
}
// if selected items should not be preserved, invalidate them
// if selected items should not be preserved, invalidate them
if(!(GetStyle() & LVS_SHOWSELALWAYS))
{
for(nItem = ListCtrl.GetNextItem(-1, LVNI_SELECTED);
nItem != -1; nItem = ListCtrl.GetNextItem(nItem, LVNI_SELECTED))
{
if (!(GetStyle() & LVS_SHOWSELALWAYS)) {
for (nItem = ListCtrl.GetNextItem(-1, LVNI_SELECTED); nItem != -1;
nItem = ListCtrl.GetNextItem(nItem, LVNI_SELECTED)) {
ListCtrl.GetItemRect(nItem, rcItem, LVIR_BOUNDS);
ListCtrl.GetItemRect(nItem, rcLabel, LVIR_LABEL);
rcItem.left = rcLabel.left;
@@ -350,7 +312,7 @@ void CListViewEx::RepaintSelectedItems()
}
}
// update changes
// update changes
UpdateWindow();
}
@@ -360,8 +322,7 @@ void CListViewEx::RepaintSelectedItems()
#ifdef _DEBUG
void CListViewEx::Dump(CDumpContext& dc) const
{
void CListViewEx::Dump(CDumpContext &dc) const {
CListView::Dump(dc);
dc << "m_bFullRowSel = " << (UINT)m_bFullRowSel;
@@ -375,58 +336,47 @@ void CListViewEx::Dump(CDumpContext& dc) const
/////////////////////////////////////////////////////////////////////////////
// CListViewEx message handlers
LRESULT CListViewEx::OnSetImageList(WPARAM wParam, LPARAM lParam)
{
if( (int) wParam == LVSIL_STATE)
{
LRESULT CListViewEx::OnSetImageList(WPARAM wParam, LPARAM lParam) {
if ((int)wParam == LVSIL_STATE) {
int cx, cy;
if(::ImageList_GetIconSize((HIMAGELIST)lParam, &cx, &cy))
if (::ImageList_GetIconSize((HIMAGELIST)lParam, &cx, &cy))
m_cxStateImageOffset = cx;
else
m_cxStateImageOffset = 0;
}
return(Default());
return (Default());
}
LRESULT CListViewEx::OnSetTextColor(WPARAM wParam, LPARAM lParam)
{
LRESULT CListViewEx::OnSetTextColor(WPARAM wParam, LPARAM lParam) {
m_clrText = (COLORREF)lParam;
return(Default());
return (Default());
}
LRESULT CListViewEx::OnSetTextBkColor(WPARAM wParam, LPARAM lParam)
{
LRESULT CListViewEx::OnSetTextBkColor(WPARAM wParam, LPARAM lParam) {
m_clrTextBk = (COLORREF)lParam;
return(Default());
return (Default());
}
LRESULT CListViewEx::OnSetBkColor(WPARAM wParam, LPARAM lParam)
{
LRESULT CListViewEx::OnSetBkColor(WPARAM wParam, LPARAM lParam) {
m_clrBkgnd = (COLORREF)lParam;
return(Default());
return (Default());
}
void CListViewEx::OnSize(UINT nType, int cx, int cy)
{
void CListViewEx::OnSize(UINT nType, int cx, int cy) {
m_cxClient = cx;
CListView::OnSize(nType, cx, cy);
}
void CListViewEx::OnPaint()
{
void CListViewEx::OnPaint() {
// in full row select mode, we need to extend the clipping region
// so we can paint a selection all the way to the right
if (m_bClientWidthSel &&
(GetStyle() & LVS_TYPEMASK) == LVS_REPORT &&
GetFullRowSel())
{
if (m_bClientWidthSel && (GetStyle() & LVS_TYPEMASK) == LVS_REPORT && GetFullRowSel()) {
CRect rcAllLabels;
GetListCtrl().GetItemRect(0, rcAllLabels, LVIR_BOUNDS);
if(rcAllLabels.right < m_cxClient)
{
if (rcAllLabels.right < m_cxClient) {
// need to call BeginPaint (in CPaintDC c-tor)
// to get correct clipping rect
CPaintDC dc(this);
@@ -434,7 +384,7 @@ void CListViewEx::OnPaint()
CRect rcClip;
dc.GetClipBox(rcClip);
rcClip.left = min(rcAllLabels.right-1, rcClip.left);
rcClip.left = min(rcAllLabels.right - 1, rcClip.left);
rcClip.right = m_cxClient;
InvalidateRect(rcClip, FALSE);
@@ -445,28 +395,26 @@ void CListViewEx::OnPaint()
CListView::OnPaint();
}
void CListViewEx::OnSetFocus(CWnd* pOldWnd)
{
void CListViewEx::OnSetFocus(CWnd *pOldWnd) {
CListView::OnSetFocus(pOldWnd);
// check if we are getting focus from label edit box
if(pOldWnd!=NULL && pOldWnd->GetParent()==this)
if (pOldWnd != NULL && pOldWnd->GetParent() == this)
return;
// repaint items that should change appearance
if(m_bFullRowSel && (GetStyle() & LVS_TYPEMASK)==LVS_REPORT)
if (m_bFullRowSel && (GetStyle() & LVS_TYPEMASK) == LVS_REPORT)
RepaintSelectedItems();
}
void CListViewEx::OnKillFocus(CWnd* pNewWnd)
{
void CListViewEx::OnKillFocus(CWnd *pNewWnd) {
CListView::OnKillFocus(pNewWnd);
// check if we are losing focus to label edit box
if(pNewWnd != NULL && pNewWnd->GetParent() == this)
if (pNewWnd != NULL && pNewWnd->GetParent() == this)
return;
// repaint items that should change appearance
if(m_bFullRowSel && (GetStyle() & LVS_TYPEMASK) == LVS_REPORT)
if (m_bFullRowSel && (GetStyle() & LVS_TYPEMASK) == LVS_REPORT)
RepaintSelectedItems();
}

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// ListVwEx.h : interface of the CListViewEx class
//
@@ -31,15 +31,14 @@
// See these sources for detailed information regarding the
// Microsoft Foundation Classes product.
class CListViewEx : public CListView
{
class CListViewEx : public CListView {
DECLARE_DYNCREATE(CListViewEx)
// Construction
// Construction
public:
CListViewEx();
// Attributes
// Attributes
protected:
BOOL m_bFullRowSel;
@@ -49,36 +48,37 @@ public:
BOOL m_bClientWidthSel;
// Overrides
// Overrides
protected:
virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CListViewEx)
public:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
public:
virtual BOOL PreCreateWindow(CREATESTRUCT &cs);
protected:
//}}AFX_VIRTUAL
// Implementation
// Implementation
public:
virtual ~CListViewEx();
#ifdef _DEBUG
virtual void Dump(CDumpContext& dc) const;
virtual void Dump(CDumpContext &dc) const;
#endif
protected:
static LPCTSTR MakeShortString(CDC* pDC, LPCTSTR lpszLong, int nColumnLen, int nOffset);
static LPCTSTR MakeShortString(CDC *pDC, LPCTSTR lpszLong, int nColumnLen, int nOffset);
void RepaintSelectedItems();
// Implementation - client area width
// Implementation - client area width
int m_cxClient;
// Implementation - state icon width
// Implementation - state icon width
int m_cxStateImageOffset;
afx_msg LRESULT OnSetImageList(WPARAM wParam, LPARAM lParam);
// Implementation - list view colors
// Implementation - list view colors
COLORREF m_clrText;
COLORREF m_clrTextBk;
COLORREF m_clrBkgnd;
@@ -86,13 +86,13 @@ protected:
afx_msg LRESULT OnSetTextBkColor(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnSetBkColor(WPARAM wParam, LPARAM lParam);
// Generated message map functions
// Generated message map functions
protected:
//{{AFX_MSG(CListViewEx)
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnPaint();
afx_msg void OnSetFocus(CWnd* pOldWnd);
afx_msg void OnKillFocus(CWnd* pNewWnd);
afx_msg void OnSetFocus(CWnd *pOldWnd);
afx_msg void OnKillFocus(CWnd *pNewWnd);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

View File

@@ -45,7 +45,6 @@
#include "pstypes.h"
#include "macros.h"
/* HOG FILE FORMAT v2.0
HOG_TAG_STR [strlen()]
@@ -60,13 +59,10 @@
FILE NFILES-1 [filelen(NFILES -1)]
*/
////////////////////////////////////////////////////////////////////////
bool CopyFile(FILE *ofp,FILE *ifp,int length)
{
#define BUFFER_SIZE (1024*1024) // 1 meg
bool CopyFile(FILE *ofp, FILE *ifp, int length) {
#define BUFFER_SIZE (1024 * 1024) // 1 meg
char *buffer;
@@ -74,19 +70,18 @@ bool CopyFile(FILE *ofp,FILE *ifp,int length)
if (!buffer)
return false;
while (length)
{
size_t n,read_len;
while (length) {
size_t n, read_len;
read_len = min(length,(int)BUFFER_SIZE);
read_len = min(length, (int)BUFFER_SIZE);
n = fread( buffer, 1, read_len, ifp );
if ( n != read_len ) {
n = fread(buffer, 1, read_len, ifp);
if (n != read_len) {
free(buffer);
return false;
}
if (fwrite( buffer, 1, read_len, ofp) != read_len ) {
if (fwrite(buffer, 1, read_len, ofp) != read_len) {
free(buffer);
return false;
}
@@ -99,10 +94,8 @@ bool CopyFile(FILE *ofp,FILE *ifp,int length)
return true;
}
bool ReadHogHeader(FILE *fp, tHogHeader *header)
{
int res=0;
bool ReadHogHeader(FILE *fp, tHogHeader *header) {
int res = 0;
res = fread(&header->nfiles, sizeof(header->nfiles), 1, fp);
res = fwrite(&header->file_data_offset, sizeof(header->file_data_offset), 1, fp);
@@ -112,10 +105,8 @@ bool ReadHogHeader(FILE *fp, tHogHeader *header)
return false;
}
bool ReadHogEntry(FILE *fp, tHogFileEntry *entry)
{
int res=0;
bool ReadHogEntry(FILE *fp, tHogFileEntry *entry) {
int res = 0;
res = fread(entry->name, strlen(entry->name), 1, fp);
res = fread(&entry->flags, sizeof(entry->flags), 1, fp);
res = fread(&entry->len, sizeof(entry->len), 1, fp);
@@ -127,10 +118,8 @@ bool ReadHogEntry(FILE *fp, tHogFileEntry *entry)
return false;
}
inline bool WRITE_FILE_ENTRY(FILE *fp, tHogFileEntry *entry)
{
int res=0;
inline bool WRITE_FILE_ENTRY(FILE *fp, tHogFileEntry *entry) {
int res = 0;
res = fwrite(entry->name, strlen(entry->name), 1, fp);
res = fwrite(&entry->flags, sizeof(entry->flags), 1, fp);
res = fwrite(&entry->len, sizeof(entry->len), 1, fp);
@@ -142,8 +131,6 @@ inline bool WRITE_FILE_ENTRY(FILE *fp, tHogFileEntry *entry)
return false;
}
////////////////////////////////////////////////////////////////////////
// create new hog file
@@ -154,8 +141,7 @@ inline bool WRITE_FILE_ENTRY(FILE *fp, tHogFileEntry *entry)
#define HOGMAKER_INFILE 4
#define HOGMAKER_COPY 5
int NewHogFile(const char *hogname, int nfiles, const char **filenames)
{
int NewHogFile(const char *hogname, int nfiles, const char **filenames) {
unsigned i;
int table_pos;
FILE *hog_fp;
@@ -163,7 +149,7 @@ int NewHogFile(const char *hogname, int nfiles, const char **filenames)
tHogFileEntry *table;
char ext[_MAX_EXT];
// allocate file table
// allocate file table
if (nfiles <= 0)
return HOGMAKER_ERROR;
@@ -171,48 +157,47 @@ int NewHogFile(const char *hogname, int nfiles, const char **filenames)
if (!table)
return HOGMAKER_MEMORY;
// create new file
hog_fp = fopen( hogname, "wb" );
if ( hog_fp == NULL ) {
// create new file
hog_fp = fopen(hogname, "wb");
if (hog_fp == NULL) {
delete[] table;
return HOGMAKER_OUTFILE;
}
//write the tag
if (!fwrite(HOG_TAG_STR, strlen(HOG_TAG_STR), 1, hog_fp )) {
// write the tag
if (!fwrite(HOG_TAG_STR, strlen(HOG_TAG_STR), 1, hog_fp)) {
delete[] table;
fclose(hog_fp);
return HOGMAKER_OUTFILE;
}
//write number of files
// write number of files
uint8_t filler = 0xff;
header.nfiles = (unsigned)nfiles;
header.file_data_offset = strlen(HOG_TAG_STR) + HOG_HDR_SIZE + (sizeof(tHogFileEntry) * header.nfiles);
if (!fwrite(&header.nfiles,sizeof(header.nfiles),1,hog_fp)) {
if (!fwrite(&header.nfiles, sizeof(header.nfiles), 1, hog_fp)) {
delete[] table;
fclose(hog_fp);
return HOGMAKER_OUTFILE;
}
if (!fwrite(&header.file_data_offset,sizeof(header.file_data_offset),1,hog_fp)) {
if (!fwrite(&header.file_data_offset, sizeof(header.file_data_offset), 1, hog_fp)) {
delete[] table;
fclose(hog_fp);
return HOGMAKER_OUTFILE;
}
if (!fwrite(&filler,sizeof(uint8_t),HOG_HDR_SIZE-sizeof(tHogHeader),hog_fp)) {
if (!fwrite(&filler, sizeof(uint8_t), HOG_HDR_SIZE - sizeof(tHogHeader), hog_fp)) {
delete[] table;
fclose(hog_fp);
return HOGMAKER_OUTFILE;
}
//save file position of index table and write out dummy table
// save file position of index table and write out dummy table
table_pos = strlen(HOG_TAG_STR) + HOG_HDR_SIZE;
memset(&table[0], 0, sizeof(table[0]));
for (i = 0; i < header.nfiles; i++)
{
for (i = 0; i < header.nfiles; i++) {
if (!WRITE_FILE_ENTRY(hog_fp, &table[0])) {
delete[] table;
fclose(hog_fp);
@@ -220,28 +205,27 @@ int NewHogFile(const char *hogname, int nfiles, const char **filenames)
}
}
//write files (& build index)
for (i=0;i<header.nfiles;i++)
{
// write files (& build index)
for (i = 0; i < header.nfiles; i++) {
FILE *ifp;
struct _stat mystat;
ifp = fopen(filenames[i],"rb");
if ( ifp == NULL ) {
ifp = fopen(filenames[i], "rb");
if (ifp == NULL) {
delete[] table;
fclose(hog_fp);
return HOGMAKER_INFILE;
}
_splitpath(filenames[i],NULL,NULL,table[i].name,ext);
_splitpath(filenames[i], NULL, NULL, table[i].name, ext);
_fstat(fileno(ifp), &mystat);
strcat(table[i].name,ext);
strcat(table[i].name, ext);
table[i].flags = 0;
table[i].len = _filelength(_fileno(ifp));
table[i].timestamp = mystat.st_mtime;
if (!CopyFile(hog_fp,ifp,table[i].len)) {
if (!CopyFile(hog_fp, ifp, table[i].len)) {
delete[] table;
fclose(hog_fp);
return HOGMAKER_COPY;
@@ -250,11 +234,10 @@ int NewHogFile(const char *hogname, int nfiles, const char **filenames)
fclose(ifp);
}
//now write the real index
fseek(hog_fp,table_pos,SEEK_SET);
// now write the real index
fseek(hog_fp, table_pos, SEEK_SET);
for (i = 0; i < header.nfiles; i++)
{
for (i = 0; i < header.nfiles; i++) {
if (!WRITE_FILE_ENTRY(hog_fp, &table[i])) {
delete[] table;
fclose(hog_fp);
@@ -262,16 +245,13 @@ int NewHogFile(const char *hogname, int nfiles, const char **filenames)
}
}
// cleanup
fclose( hog_fp );
// cleanup
fclose(hog_fp);
delete[] table;
return HOGMAKER_OK;
}
/* CopyFile
used to copy one file to another.
*/

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <dos.h>
#include <stdio.h>
@@ -23,7 +23,7 @@
#include <io.h>
#include <ctype.h>
//#include "mvlfile.h" //for old D2 movie libraries
// #include "mvlfile.h" //for old D2 movie libraries
#include "hogfile.h" //new D3 hogs
/*
@@ -464,9 +464,8 @@ show_help()
printf( " x extract files\n");
}
*/
int main(int argc, char * argv[] )
{
/* char command;
int main(int argc, char *argv[]) {
/* char command;
char *hogname;
if ( argc < 3 ) {
@@ -493,7 +492,6 @@ int main(int argc, char * argv[] )
show_help();
exit(2);
}
*/
*/
return 0;
}

View File

@@ -64,8 +64,8 @@
#include <stdlib.h>
#ifdef __LINUX__
//sorry, I'm lazy, I guess we could copy the defines
//that we need to transalte winsock->linux into this header...but no need to now
// sorry, I'm lazy, I guess we could copy the defines
// that we need to transalte winsock->linux into this header...but no need to now
#include "inetgetfile.h"
#endif
@@ -76,26 +76,25 @@
#include "CFtp.h"
#ifdef __LINUX__
void *FTPObjThread( void * obj )
void *FTPObjThread(void *obj)
#else
void FTPObjThread( void * obj )
void FTPObjThread(void *obj)
#endif
{
((CFtpGet *)obj)->WorkerThread();
#ifdef __LINUX__
#ifdef __LINUX__
return NULL;
#endif
#endif
}
void CFtpGet::AbortGet()
{
void CFtpGet::AbortGet() {
m_Aborting = true;
while(!m_Aborted) ; //Wait for the thread to end
while (!m_Aborted)
; // Wait for the thread to end
fclose(LOCALFILE);
}
CFtpGet::CFtpGet(char *URL,char *localfile,char *Username,char *Password)
{
CFtpGet::CFtpGet(char *URL, char *localfile, char *Username, char *Password) {
SOCKADDR_IN listensockaddr;
m_State = FTP_STATE_STARTUP;
@@ -107,133 +106,106 @@ CFtpGet::CFtpGet(char *URL,char *localfile,char *Username,char *Password)
m_Aborting = false;
m_Aborted = false;
LOCALFILE = fopen(localfile,"wb");
if(NULL == LOCALFILE)
{
LOCALFILE = fopen(localfile, "wb");
if (NULL == LOCALFILE) {
m_State = FTP_STATE_CANT_WRITE_FILE;
return;
}
if(Username)
{
strcpy(m_szUserName,Username);
if (Username) {
strcpy(m_szUserName, Username);
} else {
strcpy(m_szUserName, "anonymous");
}
else
{
strcpy(m_szUserName,"anonymous");
}
if(Password)
{
strcpy(m_szPassword,Password);
}
else
{
strcpy(m_szPassword,"pxouser@pxo.net");
if (Password) {
strcpy(m_szPassword, Password);
} else {
strcpy(m_szPassword, "pxouser@pxo.net");
}
m_ListenSock = socket(AF_INET, SOCK_STREAM, 0);
if(INVALID_SOCKET == m_ListenSock)
{
if (INVALID_SOCKET == m_ListenSock) {
int iWinsockErr = WSAGetLastError();
m_State = FTP_STATE_SOCKET_ERROR;
return;
}
else
{
} else {
listensockaddr.sin_family = AF_INET;
listensockaddr.sin_port = 0;
listensockaddr.sin_addr.s_addr = INADDR_ANY;
// Bind the listen socket
if (bind(m_ListenSock, (SOCKADDR *)&listensockaddr, sizeof(SOCKADDR)))
{
//Couldn't bind the socket
if (bind(m_ListenSock, (SOCKADDR *)&listensockaddr, sizeof(SOCKADDR))) {
// Couldn't bind the socket
int iWinsockErr = WSAGetLastError();
m_State = FTP_STATE_SOCKET_ERROR;
return;
}
// Listen for the server connection
if (listen(m_ListenSock, 1))
{
//Couldn't listen on the socket
if (listen(m_ListenSock, 1)) {
// Couldn't listen on the socket
int iWinsockErr = WSAGetLastError();
m_State = FTP_STATE_SOCKET_ERROR;
return;
}
}
m_ControlSock = socket(AF_INET, SOCK_STREAM, 0);
if(INVALID_SOCKET == m_ControlSock)
{
if (INVALID_SOCKET == m_ControlSock) {
m_State = FTP_STATE_SOCKET_ERROR;
return;
}
//Parse the URL
//Get rid of any extra ftp:// stuff
// Parse the URL
// Get rid of any extra ftp:// stuff
char *pURL = URL;
if(strnicmp(URL,"ftp:",4)==0)
{
pURL +=4;
while(*pURL == '/')
{
if (strnicmp(URL, "ftp:", 4) == 0) {
pURL += 4;
while (*pURL == '/') {
pURL++;
}
}
//There shouldn't be any : in this string
if(strchr(pURL,':'))
{
// There shouldn't be any : in this string
if (strchr(pURL, ':')) {
m_State = FTP_STATE_URL_PARSING_ERROR;
return;
}
//read the filename by searching backwards for a /
//then keep reading until you find the first /
//when you found it, you have the host and dir
// read the filename by searching backwards for a /
// then keep reading until you find the first /
// when you found it, you have the host and dir
char *filestart = NULL;
char *dirstart;
for(int i = strlen(pURL);i>=0;i--)
{
if(pURL[i]== '/')
{
if(!filestart)
{
filestart = pURL+i+1;
dirstart = pURL+i+1;
strcpy(m_szFilename,filestart);
}
else
{
dirstart = pURL+i+1;
for (int i = strlen(pURL); i >= 0; i--) {
if (pURL[i] == '/') {
if (!filestart) {
filestart = pURL + i + 1;
dirstart = pURL + i + 1;
strcpy(m_szFilename, filestart);
} else {
dirstart = pURL + i + 1;
}
}
}
if((dirstart==NULL) || (filestart==NULL))
{
if ((dirstart == NULL) || (filestart == NULL)) {
m_State = FTP_STATE_URL_PARSING_ERROR;
return;
} else {
strncpy(m_szDir, dirstart, (filestart - dirstart));
m_szDir[(filestart - dirstart)] = '\0';
strncpy(m_szHost, pURL, (dirstart - pURL));
m_szHost[(dirstart - pURL) - 1] = '\0';
}
else
{
strncpy(m_szDir,dirstart,(filestart-dirstart));
m_szDir[(filestart-dirstart)] = '\0';
strncpy(m_szHost,pURL,(dirstart-pURL));
m_szHost[(dirstart-pURL)-1] = '\0';
}
//At this point we should have a nice host,dir and filename
// At this point we should have a nice host,dir and filename
#ifdef WIN32
if(NULL==_beginthread(FTPObjThread,0,this))
{
if (NULL == _beginthread(FTPObjThread, 0, this)) {
m_State = FTP_STATE_INTERNAL_ERROR;
return;
}
#elif defined(__LINUX__)
pthread_t thread;
if(!inet_LoadThreadLib())
{
if (!inet_LoadThreadLib()) {
m_State = FTP_STATE_INTERNAL_ERROR;
return;
}
if(df_pthread_create(&thread,NULL,FTPObjThread,this)!=0)
{
if (df_pthread_create(&thread, NULL, FTPObjThread, this) != 0) {
m_State = FTP_STATE_INTERNAL_ERROR;
return;
}
@@ -241,152 +213,121 @@ CFtpGet::CFtpGet(char *URL,char *localfile,char *Username,char *Password)
m_State = FTP_STATE_CONNECTING;
}
CFtpGet::~CFtpGet()
{
if(m_ListenSock != INVALID_SOCKET)
{
shutdown(m_ListenSock,2);
#ifndef __LINUX__
CFtpGet::~CFtpGet() {
if (m_ListenSock != INVALID_SOCKET) {
shutdown(m_ListenSock, 2);
#ifndef __LINUX__
closesocket(m_ListenSock);
#else
#else
close(m_ListenSock);
#endif
#endif
}
if(m_DataSock != INVALID_SOCKET)
{
shutdown(m_DataSock,2);
#ifndef __LINUX__
if (m_DataSock != INVALID_SOCKET) {
shutdown(m_DataSock, 2);
#ifndef __LINUX__
closesocket(m_DataSock);
#else
#else
close(m_DataSock);
#endif
#endif
}
if(m_ControlSock != INVALID_SOCKET)
{
shutdown(m_ControlSock,2);
#ifndef __LINUX__
if (m_ControlSock != INVALID_SOCKET) {
shutdown(m_ControlSock, 2);
#ifndef __LINUX__
closesocket(m_ControlSock);
#else
#else
close(m_ControlSock);
#endif
#endif
}
}
//Returns a value to specify the status (ie. connecting/connected/transferring/done)
int CFtpGet::GetStatus()
{
return m_State;
}
// Returns a value to specify the status (ie. connecting/connected/transferring/done)
int CFtpGet::GetStatus() { return m_State; }
uint32_t CFtpGet::GetBytesIn()
{
return m_iBytesIn;
}
uint32_t CFtpGet::GetBytesIn() { return m_iBytesIn; }
uint32_t CFtpGet::GetTotalBytes()
{
uint32_t CFtpGet::GetTotalBytes() { return m_iBytesTotal; }
return m_iBytesTotal;
}
//This function does all the work -- connects on a blocking socket
//then sends the appropriate user and password commands
//and then the cwd command, the port command then get and finally the quit
void CFtpGet::WorkerThread()
{
// This function does all the work -- connects on a blocking socket
// then sends the appropriate user and password commands
// and then the cwd command, the port command then get and finally the quit
void CFtpGet::WorkerThread() {
ConnectControlSocket();
if(m_State != FTP_STATE_LOGGING_IN)
{
if (m_State != FTP_STATE_LOGGING_IN) {
return;
}
LoginHost();
if(m_State != FTP_STATE_LOGGED_IN)
{
if (m_State != FTP_STATE_LOGGED_IN) {
return;
}
GetFile();
//We are all done now, and state has the current state.
// We are all done now, and state has the current state.
m_Aborted = true;
}
uint32_t CFtpGet::GetFile()
{
uint32_t CFtpGet::GetFile() {
//Start off by changing into the proper dir.
// Start off by changing into the proper dir.
char szCommandString[200];
int rcode;
sprintf(szCommandString,"TYPE I\r\n");
sprintf(szCommandString, "TYPE I\r\n");
rcode = SendFTPCommand(szCommandString);
if(rcode >=400)
{
if (rcode >= 400) {
m_State = FTP_STATE_UNKNOWN_ERROR;
return 0;
}
if(m_Aborting)
if (m_Aborting)
return 0;
if(m_szDir[0])
{
sprintf(szCommandString,"CWD %s\r\n",m_szDir);
if (m_szDir[0]) {
sprintf(szCommandString, "CWD %s\r\n", m_szDir);
rcode = SendFTPCommand(szCommandString);
if(rcode >=400)
{
if (rcode >= 400) {
m_State = FTP_STATE_DIRECTORY_INVALID;
return 0;
}
}
if(m_Aborting)
if (m_Aborting)
return 0;
if(!IssuePort())
{
if (!IssuePort()) {
m_State = FTP_STATE_UNKNOWN_ERROR;
return 0;
}
if(m_Aborting)
if (m_Aborting)
return 0;
sprintf(szCommandString,"RETR %s\r\n",m_szFilename);
sprintf(szCommandString, "RETR %s\r\n", m_szFilename);
rcode = SendFTPCommand(szCommandString);
if(rcode >=400)
{
if (rcode >= 400) {
m_State = FTP_STATE_FILE_NOT_FOUND;
return 0;
}
if(m_Aborting)
if (m_Aborting)
return 0;
//Now we will try to determine the file size...
char *p,*s;
p = strchr(recv_buffer,'(');
if(p)
{
// Now we will try to determine the file size...
char *p, *s;
p = strchr(recv_buffer, '(');
if (p) {
p++;
s = strchr(p,' ');
s = strchr(p, ' ');
*s = '\0';
m_iBytesTotal = atoi(p);
}
if(m_Aborting)
if (m_Aborting)
return 0;
m_DataSock = accept(m_ListenSock, NULL,NULL);//(SOCKADDR *)&sockaddr,&iAddrLength);
m_DataSock = accept(m_ListenSock, NULL, NULL); //(SOCKADDR *)&sockaddr,&iAddrLength);
// Close the listen socket
#ifndef __LINUX__
closesocket(m_ListenSock);
#else
close(m_ListenSock);
#endif
if (m_DataSock == INVALID_SOCKET)
{
if (m_DataSock == INVALID_SOCKET) {
int iWinsockErr = WSAGetLastError();
m_State = FTP_STATE_SOCKET_ERROR;
return 0;
}
if(m_Aborting)
if (m_Aborting)
return 0;
ReadDataChannel();
@@ -395,8 +336,7 @@ uint32_t CFtpGet::GetFile()
return 1;
}
uint32_t CFtpGet::IssuePort()
{
uint32_t CFtpGet::IssuePort() {
char szCommandString[200];
SOCKADDR_IN listenaddr; // Socket address structure
@@ -404,11 +344,9 @@ uint32_t CFtpGet::IssuePort()
uint32_t nLocalPort; // Local port for listening
uint32_t nReplyCode; // FTP server reply code
// Get the address for the hListenSocket
iLength = sizeof(listenaddr);
if (getsockname(m_ListenSock, (SOCKADDR *)&listenaddr,&iLength) == SOCKET_ERROR)
{
if (getsockname(m_ListenSock, (SOCKADDR *)&listenaddr, &iLength) == SOCKET_ERROR) {
int iWinsockErr = WSAGetLastError();
m_State = FTP_STATE_SOCKET_ERROR;
return 0;
@@ -419,50 +357,43 @@ uint32_t CFtpGet::IssuePort()
// Now, reuse the socket address structure to
// get the IP address from the control socket.
if (getsockname(m_ControlSock, (SOCKADDR *)&listenaddr,&iLength) == SOCKET_ERROR)
{
if (getsockname(m_ControlSock, (SOCKADDR *)&listenaddr, &iLength) == SOCKET_ERROR) {
int iWinsockErr = WSAGetLastError();
m_State = FTP_STATE_SOCKET_ERROR;
return 0;
}
#ifdef WIN32
#ifdef WIN32
// Format the PORT command with the correct numbers.
sprintf(szCommandString, "PORT %d,%d,%d,%d,%d,%d\r\n",
listenaddr.sin_addr.S_un.S_un_b.s_b1,
listenaddr.sin_addr.S_un.S_un_b.s_b2,
listenaddr.sin_addr.S_un.S_un_b.s_b3,
listenaddr.sin_addr.S_un.S_un_b.s_b4,
nLocalPort & 0xFF,
nLocalPort >> 8);
#else
union{
struct{ uint8_t s_b1,s_b2,s_b3,s_b4;}S_un_b;
struct{ uint16_t s_w1,s_w2;} S_un_w;
sprintf(szCommandString, "PORT %d,%d,%d,%d,%d,%d\r\n", listenaddr.sin_addr.S_un.S_un_b.s_b1,
listenaddr.sin_addr.S_un.S_un_b.s_b2, listenaddr.sin_addr.S_un.S_un_b.s_b3,
listenaddr.sin_addr.S_un.S_un_b.s_b4, nLocalPort & 0xFF, nLocalPort >> 8);
#else
union {
struct {
uint8_t s_b1, s_b2, s_b3, s_b4;
} S_un_b;
struct {
uint16_t s_w1, s_w2;
} S_un_w;
uint32_t S_addr;
}S_un;
} S_un;
S_un.S_addr = (uint32_t)listenaddr.sin_addr.s_addr;
// Format the PORT command with the correct numbers.
sprintf(szCommandString, "PORT %d,%d,%d,%d,%d,%d\r\n",
S_un.S_un_b.s_b1,
S_un.S_un_b.s_b2,
S_un.S_un_b.s_b3,
S_un.S_un_b.s_b4,
nLocalPort & 0xFF,
nLocalPort >> 8);
#endif
sprintf(szCommandString, "PORT %d,%d,%d,%d,%d,%d\r\n", S_un.S_un_b.s_b1, S_un.S_un_b.s_b2, S_un.S_un_b.s_b3,
S_un.S_un_b.s_b4, nLocalPort & 0xFF, nLocalPort >> 8);
#endif
// Tell the server which port to use for data.
nReplyCode = SendFTPCommand(szCommandString);
if (nReplyCode!= 200 )
{
#ifdef __LINUX__
if (nReplyCode != 200) {
#ifdef __LINUX__
// I don't know if this is just Linux or do to a bug I fixed while porting to linux
// for some reason I kept getting reply 250 here and have to read again to get the
// "200 PORT Command OK" or whatever
if(nReplyCode!=250 || (ReadFTPServerReply()!=200))//ummmmmmmm
#endif
if (nReplyCode != 250 || (ReadFTPServerReply() != 200)) // ummmmmmmm
#endif
{
int iWinsockErr = WSAGetLastError();
m_State = FTP_STATE_SOCKET_ERROR;
@@ -473,37 +404,31 @@ uint32_t CFtpGet::IssuePort()
return 1;
}
int CFtpGet::ConnectControlSocket()
{
int CFtpGet::ConnectControlSocket() {
HOSTENT *he;
SERVENT *se;
SOCKADDR_IN hostaddr;
he = gethostbyname(m_szHost);
if(he == NULL)
{
if (he == NULL) {
m_State = FTP_STATE_HOST_NOT_FOUND;
return 0;
}
//m_ControlSock
if(m_Aborting)
// m_ControlSock
if (m_Aborting)
return 0;
se = getservbyname("ftp", NULL);
if(se == NULL)
{
if (se == NULL) {
hostaddr.sin_port = htons(21);
}
else
{
} else {
hostaddr.sin_port = se->s_port;
}
hostaddr.sin_family = AF_INET;
memcpy(&hostaddr.sin_addr,he->h_addr_list[0],4);
if(m_Aborting)
memcpy(&hostaddr.sin_addr, he->h_addr_list[0], 4);
if (m_Aborting)
return 0;
//Now we will connect to the host
if(connect(m_ControlSock, (SOCKADDR *)&hostaddr, sizeof(SOCKADDR)))
{
// Now we will connect to the host
if (connect(m_ControlSock, (SOCKADDR *)&hostaddr, sizeof(SOCKADDR))) {
int iWinsockErr = WSAGetLastError();
m_State = FTP_STATE_CANT_CONNECT;
return 0;
@@ -512,23 +437,19 @@ int CFtpGet::ConnectControlSocket()
return 1;
}
int CFtpGet::LoginHost()
{
int CFtpGet::LoginHost() {
char szLoginString[200];
int rcode;
sprintf(szLoginString,"USER %s\r\n",m_szUserName);
sprintf(szLoginString, "USER %s\r\n", m_szUserName);
rcode = SendFTPCommand(szLoginString);
if(rcode >=400)
{
if (rcode >= 400) {
m_State = FTP_STATE_LOGIN_ERROR;
return 0;
}
sprintf(szLoginString,"PASS %s\r\n",m_szPassword);
sprintf(szLoginString, "PASS %s\r\n", m_szPassword);
rcode = SendFTPCommand(szLoginString);
if(rcode >=400)
{
if (rcode >= 400) {
m_State = FTP_STATE_LOGIN_ERROR;
return 0;
}
@@ -537,150 +458,121 @@ int CFtpGet::LoginHost()
return 1;
}
uint32_t CFtpGet::SendFTPCommand(char *command)
{
uint32_t CFtpGet::SendFTPCommand(char *command) {
FlushControlChannel();
// Send the FTP command
if (SOCKET_ERROR ==(send(m_ControlSock,command,strlen(command), 0)))
{
if (SOCKET_ERROR == (send(m_ControlSock, command, strlen(command), 0))) {
int iWinsockErr = WSAGetLastError();
// Return 999 to indicate an error has occurred
return(999);
return (999);
}
// Read the server's reply and return the reply code as an integer
return(ReadFTPServerReply());
return (ReadFTPServerReply());
}
uint32_t CFtpGet::ReadFTPServerReply()
{
uint32_t CFtpGet::ReadFTPServerReply() {
uint32_t rcode;
uint32_t iBytesRead;
char chunk[2];
char szcode[5];
uint32_t igotcrlf = 0;
memset(recv_buffer,0,1000);
do
{
chunk[0]='\0';
iBytesRead = recv(m_ControlSock,chunk,1,0);
memset(recv_buffer, 0, 1000);
do {
chunk[0] = '\0';
iBytesRead = recv(m_ControlSock, chunk, 1, 0);
if (iBytesRead == SOCKET_ERROR)
{
if (iBytesRead == SOCKET_ERROR) {
int iWinsockErr = WSAGetLastError();
#ifdef __LINUX__
if(0==iWinsockErr)
{
#ifdef __LINUX__
if (0 == iWinsockErr) {
continue;
}
#endif
#endif
// Return 999 to indicate an error has occurred
return(999);
return (999);
}
if((chunk[0]==0x0a) || (chunk[0]==0x0d))
{
if(recv_buffer[0]!='\0')
{
if ((chunk[0] == 0x0a) || (chunk[0] == 0x0d)) {
if (recv_buffer[0] != '\0') {
igotcrlf = 1;
}
}
else
{ chunk[1] = '\0';
strcat(recv_buffer,chunk);
} else {
chunk[1] = '\0';
strcat(recv_buffer, chunk);
}
} while (igotcrlf == 0);
}while(igotcrlf==0);
if(recv_buffer[3] == '-')
{
//Hack -- must be a MOTD
if (recv_buffer[3] == '-') {
// Hack -- must be a MOTD
return ReadFTPServerReply();
}
if(recv_buffer[3] != ' ')
{
//We should have 3 numbers then a space
if (recv_buffer[3] != ' ') {
// We should have 3 numbers then a space
return 999;
}
memcpy(szcode,recv_buffer,3);
memcpy(szcode, recv_buffer, 3);
szcode[3] = '\0';
rcode = atoi(szcode);
// Extract the reply code from the server reply and return as an integer
return(rcode);
return (rcode);
}
uint32_t CFtpGet::ReadDataChannel()
{
uint32_t CFtpGet::ReadDataChannel() {
char sDataBuffer[4096]; // Data-storage buffer for the data channel
int nBytesRecv; // Bytes received from the data channel
m_State = FTP_STATE_RECEIVING;
if(m_Aborting)
if (m_Aborting)
return 0;
do
{
if(m_Aborting)
do {
if (m_Aborting)
return 0;
nBytesRecv = recv(m_DataSock, (char *)&sDataBuffer,sizeof(sDataBuffer), 0);
nBytesRecv = recv(m_DataSock, (char *)&sDataBuffer, sizeof(sDataBuffer), 0);
#ifdef __LINUX__
if(nBytesRecv==-1)
{
#ifdef __LINUX__
if (nBytesRecv == -1) {
int iWinsockErr = WSAGetLastError();
if(iWinsockErr==0)
{
if (iWinsockErr == 0) {
nBytesRecv = 1;
continue;
}
}
#endif
#endif
m_iBytesIn += nBytesRecv;
if (nBytesRecv > 0 )
{
fwrite(sDataBuffer,nBytesRecv,1,LOCALFILE);
//Write sDataBuffer, nBytesRecv
if (nBytesRecv > 0) {
fwrite(sDataBuffer, nBytesRecv, 1, LOCALFILE);
// Write sDataBuffer, nBytesRecv
}
}while (nBytesRecv > 0);
} while (nBytesRecv > 0);
fclose(LOCALFILE);
// Close the file and check for error returns.
if (nBytesRecv == SOCKET_ERROR)
{
//Ok, we got a socket error -- xfer aborted?
if (nBytesRecv == SOCKET_ERROR) {
// Ok, we got a socket error -- xfer aborted?
m_State = FTP_STATE_RECV_FAILED;
return 0;
}
else
{
//done!
} else {
// done!
m_State = FTP_STATE_FILE_RECEIVED;
return 1;
}
}
void CFtpGet::FlushControlChannel()
{
void CFtpGet::FlushControlChannel() {
fd_set read_fds;
TIMEVAL timeout;
int bytesin = 0;
char flushbuff[3];
timeout.tv_sec=0;
timeout.tv_usec=0;
timeout.tv_sec = 0;
timeout.tv_usec = 0;
FD_ZERO(&read_fds);
FD_SET(m_ControlSock,&read_fds);
FD_SET(m_ControlSock, &read_fds);
while(select(m_ControlSock+1,&read_fds,NULL,NULL,&timeout))
{
recv(m_ControlSock,flushbuff,1,0);
while (select(m_ControlSock + 1, &read_fds, NULL, NULL, &timeout)) {
recv(m_ControlSock, flushbuff, 1, 0);
}
}

View File

@@ -131,12 +131,11 @@
#ifdef __LINUX__
inline void Sleep(int millis)
{
inline void Sleep(int millis) {
struct timeval tv;
tv.tv_sec = 0;
tv.tv_usec = millis*1000;
select(0,NULL,NULL,NULL,&tv);
tv.tv_usec = millis * 1000;
select(0, NULL, NULL, NULL, &tv);
}
#endif
@@ -150,55 +149,51 @@ void __cdecl http_gethostbynameworker(void *parm);
void *http_gethostbynameworker(void *parm);
#endif
int http_Asyncgethostbyname(uint32_t *ip,int command, char *hostname);
int http_Asyncgethostbyname(uint32_t *ip, int command, char *hostname);
#ifndef __LINUX__
void HTTPObjThread( void * obj )
void HTTPObjThread(void *obj)
#else
void *HTTPObjThread( void * obj )
void *HTTPObjThread(void *obj)
#endif
{
((ChttpGet *)obj)->WorkerThread();
((ChttpGet *)obj)->m_Aborted = true;
//OutputDebugString("http transfer exiting....\n");
// OutputDebugString("http transfer exiting....\n");
#ifdef __LINUX__
#ifdef __LINUX__
return NULL;
#endif
#endif
}
void ChttpGet::AbortGet()
{
void ChttpGet::AbortGet() {
#ifdef WIN32
OutputDebugString("Aborting....\n");
#endif
m_Aborting = true;
while(!m_Aborted) Sleep(50); //Wait for the thread to end
while (!m_Aborted)
Sleep(50); // Wait for the thread to end
#ifdef WIN32
OutputDebugString("Aborted....\n");
#endif
}
ChttpGet::ChttpGet(char *URL,char *localfile,char *proxyip,uint16_t proxyport)
{
ChttpGet::ChttpGet(char *URL, char *localfile, char *proxyip, uint16_t proxyport) {
m_ProxyEnabled = true;
m_ProxyIP = proxyip;
m_ProxyPort = proxyport;
GetFile(URL,localfile);
GetFile(URL, localfile);
}
ChttpGet::ChttpGet(char *URL,char *localfile)
{
ChttpGet::ChttpGet(char *URL, char *localfile) {
m_ProxyEnabled = false;
GetFile(URL,localfile);
GetFile(URL, localfile);
}
void ChttpGet::PrepSocket(char *URL)
{
void ChttpGet::PrepSocket(char *URL) {
m_DataSock = socket(AF_INET, SOCK_STREAM, 0);
if(INVALID_SOCKET == m_DataSock)
{
if (INVALID_SOCKET == m_DataSock) {
m_State = HTTP_STATE_SOCKET_ERROR;
return;
}
@@ -206,72 +201,58 @@ void ChttpGet::PrepSocket(char *URL)
make_nonblocking(m_DataSock);
char *pURL = URL;
if(strnicmp(URL,"http:",5)==0)
{
pURL +=5;
while(*pURL == '/')
{
if (strnicmp(URL, "http:", 5) == 0) {
pURL += 5;
while (*pURL == '/') {
pURL++;
}
}
//There shouldn't be any : in this string
if(strchr(pURL,':'))
{
// There shouldn't be any : in this string
if (strchr(pURL, ':')) {
m_State = HTTP_STATE_URL_PARSING_ERROR;
return;
}
//read the filename by searching backwards for a /
//then keep reading until you find the first /
//when you found it, you have the host and dir
// read the filename by searching backwards for a /
// then keep reading until you find the first /
// when you found it, you have the host and dir
char *filestart = NULL;
char *dirstart;
for(int i = strlen(pURL);i>=0;i--)
{
if(pURL[i]== '/')
{
if(!filestart)
{
filestart = pURL+i+1;
dirstart = pURL+i+1;
strcpy(m_szFilename,filestart);
}
else
{
dirstart = pURL+i+1;
for (int i = strlen(pURL); i >= 0; i--) {
if (pURL[i] == '/') {
if (!filestart) {
filestart = pURL + i + 1;
dirstart = pURL + i + 1;
strcpy(m_szFilename, filestart);
} else {
dirstart = pURL + i + 1;
}
}
}
if((dirstart==NULL) || (filestart==NULL))
{
if ((dirstart == NULL) || (filestart == NULL)) {
m_State = HTTP_STATE_URL_PARSING_ERROR;
return;
} else {
strcpy(m_szDir, dirstart); //,(filestart-dirstart));
// m_szDir[(filestart-dirstart)] = NULL;
strncpy(m_szHost, pURL, (dirstart - pURL));
m_szHost[(dirstart - pURL) - 1] = '\0';
}
else
{
strcpy(m_szDir,dirstart);//,(filestart-dirstart));
//m_szDir[(filestart-dirstart)] = NULL;
strncpy(m_szHost,pURL,(dirstart-pURL));
m_szHost[(dirstart-pURL)-1] = '\0';
}
}
void ChttpGet::GetFile(char *URL,char *localfile)
{
void ChttpGet::GetFile(char *URL, char *localfile) {
m_DataSock = INVALID_SOCKET;
m_iBytesIn = 0;
m_iBytesTotal = 0;
m_State = HTTP_STATE_STARTUP;;
m_State = HTTP_STATE_STARTUP;
;
m_Aborting = false;
m_Aborted = false;
strncpy(m_URL,URL,MAX_URL_LEN-1);
m_URL[MAX_URL_LEN-1] = 0;
strncpy(m_URL, URL, MAX_URL_LEN - 1);
m_URL[MAX_URL_LEN - 1] = 0;
LOCALFILE = fopen(localfile,"wb");
if(NULL == LOCALFILE)
{
LOCALFILE = fopen(localfile, "wb");
if (NULL == LOCALFILE) {
m_State = HTTP_STATE_CANT_WRITE_FILE;
return;
}
@@ -279,32 +260,26 @@ void ChttpGet::GetFile(char *URL,char *localfile)
PrepSocket(URL);
#ifdef WIN32
if(NULL==_beginthread(HTTPObjThread,0,this))
{
if (NULL == _beginthread(HTTPObjThread, 0, this)) {
m_State = HTTP_STATE_INTERNAL_ERROR;
return;
}
#elif defined(__LINUX__)
pthread_t thread;
if(!inet_LoadThreadLib())
{
if (!inet_LoadThreadLib()) {
m_State = HTTP_STATE_INTERNAL_ERROR;
return;
}
if(df_pthread_create(&thread,NULL,HTTPObjThread,this)!=0)
{
if (df_pthread_create(&thread, NULL, HTTPObjThread, this) != 0) {
m_State = HTTP_STATE_INTERNAL_ERROR;
return;
}
#endif
}
ChttpGet::~ChttpGet()
{
if(m_DataSock != INVALID_SOCKET)
{
shutdown(m_DataSock,2);
ChttpGet::~ChttpGet() {
if (m_DataSock != INVALID_SOCKET) {
shutdown(m_DataSock, 2);
#ifndef __LINUX__
closesocket(m_DataSock);
#else
@@ -313,245 +288,194 @@ ChttpGet::~ChttpGet()
}
}
int ChttpGet::GetStatus()
{
return m_State;
}
int ChttpGet::GetStatus() { return m_State; }
uint32_t ChttpGet::GetBytesIn()
{
return m_iBytesIn;
}
uint32_t ChttpGet::GetBytesIn() { return m_iBytesIn; }
uint32_t ChttpGet::GetTotalBytes()
{
return m_iBytesTotal;
}
uint32_t ChttpGet::GetTotalBytes() { return m_iBytesTotal; }
void ChttpGet::WorkerThread()
{
void ChttpGet::WorkerThread() {
char szCommand[1000];
char *p;
int irsp = 0;
ConnectSocket();
if(m_Aborting)
{
if (m_Aborting) {
fclose(LOCALFILE);
return;
}
if(m_State != HTTP_STATE_CONNECTED)
{
if (m_State != HTTP_STATE_CONNECTED) {
fclose(LOCALFILE);
return;
}
sprintf(szCommand,"GET %s%s HTTP/1.1\nAccept: */*\nAccept-Encoding: deflate\nHost: %s\n\n\n",m_ProxyEnabled?"":"/",m_ProxyEnabled?m_URL:m_szDir,m_szHost);
send(m_DataSock,szCommand,strlen(szCommand),0);
sprintf(szCommand, "GET %s%s HTTP/1.1\nAccept: */*\nAccept-Encoding: deflate\nHost: %s\n\n\n",
m_ProxyEnabled ? "" : "/", m_ProxyEnabled ? m_URL : m_szDir, m_szHost);
send(m_DataSock, szCommand, strlen(szCommand), 0);
p = GetHTTPLine();
if(p && strnicmp("HTTP/",p,5)==0)
{
if (p && strnicmp("HTTP/", p, 5) == 0) {
char *pcode;
pcode = strchr(p,' ')+1;
if(!pcode)
{
pcode = strchr(p, ' ') + 1;
if (!pcode) {
m_State = HTTP_STATE_UNKNOWN_ERROR;
fclose(LOCALFILE);
return;
}
pcode[3] = '\0';
irsp = atoi(pcode);
if(irsp == 0)
{
if (irsp == 0) {
m_State = HTTP_STATE_UNKNOWN_ERROR;
fclose(LOCALFILE);
return;
}
if(irsp == 301)
{
if (irsp == 301) {
//This is a redirection! woohoo, what fun we are going to have.
//Next thing we need to do is find where it's redirected to.
//We do that by looking for a "Location: xxxx" line.
// This is a redirection! woohoo, what fun we are going to have.
// Next thing we need to do is find where it's redirected to.
// We do that by looking for a "Location: xxxx" line.
int idataready=0;
do
{
int idataready = 0;
do {
p = GetHTTPLine();
if(p==NULL)
{
if (p == NULL) {
m_State = HTTP_STATE_UNKNOWN_ERROR;
fclose(LOCALFILE);
return;
}
if(*p=='\0')
{
if (*p == '\0') {
idataready = 1;
break;
}
if(strnicmp(p,"Location:",strlen("Location:"))==0)
{
char *s = strchr(p,' ')+1;
if (strnicmp(p, "Location:", strlen("Location:")) == 0) {
char *s = strchr(p, ' ') + 1;
// Then, once we've found that, we close the sockets & reissue the whole freakin request.
shutdown(m_DataSock, 2);
//Then, once we've found that, we close the sockets & reissue the whole freakin request.
shutdown(m_DataSock,2);
#ifdef WIN32
#ifdef WIN32
closesocket(m_DataSock);
#else
#else
close(m_DataSock);
#endif
#endif
m_DataSock = INVALID_SOCKET;
//New location to look at is in 's'
// New location to look at is in 's'
PrepSocket(s);
WorkerThread();
return;
}
}while(!idataready);
} while (!idataready);
}
if(irsp==200)
{
int idataready=0;
do
{
if (irsp == 200) {
int idataready = 0;
do {
p = GetHTTPLine();
if(p==NULL)
{
if (p == NULL) {
m_State = HTTP_STATE_UNKNOWN_ERROR;
fclose(LOCALFILE);
return;
}
if(*p=='\0')
{
if (*p == '\0') {
idataready = 1;
break;
}
if(strnicmp(p,"Content-Length:",strlen("Content-Length:"))==0)
{
char *s = strchr(p,' ')+1;
if (strnicmp(p, "Content-Length:", strlen("Content-Length:")) == 0) {
char *s = strchr(p, ' ') + 1;
p = s;
if(s)
{
while(*s)
{
if(!isdigit(*s))
{
*s='\0';
if (s) {
while (*s) {
if (!isdigit(*s)) {
*s = '\0';
}
s++;
};
m_iBytesTotal = atoi(p);
}
}
}while(!idataready);
} while (!idataready);
ReadDataChannel();
return;
}
m_State = HTTP_STATE_FILE_NOT_FOUND;
fclose(LOCALFILE);
return;
}
else
{
} else {
m_State = HTTP_STATE_UNKNOWN_ERROR;
fclose(LOCALFILE);
return;
}
}
int ChttpGet::ConnectSocket()
{
//HOSTENT *he;
int ChttpGet::ConnectSocket() {
// HOSTENT *he;
uint32_t ip;
SERVENT *se;
SOCKADDR_IN hostaddr;
int rcode = 0;
if(m_Aborting)
if (m_Aborting)
return 0;
ip = inet_addr((const char *)m_szHost);
if(ip==INADDR_NONE)
{
http_Asyncgethostbyname(&ip,NW_AGHBN_LOOKUP,m_szHost);
if (ip == INADDR_NONE) {
http_Asyncgethostbyname(&ip, NW_AGHBN_LOOKUP, m_szHost);
rcode = 0;
do
{
if(m_Aborting)
{
http_Asyncgethostbyname(&ip,NW_AGHBN_CANCEL,m_szHost);
do {
if (m_Aborting) {
http_Asyncgethostbyname(&ip, NW_AGHBN_CANCEL, m_szHost);
return 0;
}
rcode = http_Asyncgethostbyname(&ip,NW_AGHBN_READ,m_szHost);
}while(rcode==0);
rcode = http_Asyncgethostbyname(&ip, NW_AGHBN_READ, m_szHost);
} while (rcode == 0);
}
if(rcode == -1)
{
if (rcode == -1) {
m_State = HTTP_STATE_HOST_NOT_FOUND;
return 0;
}
//m_ControlSock
if(m_Aborting)
// m_ControlSock
if (m_Aborting)
return 0;
se = getservbyname("http", NULL);
if(m_Aborting)
if (m_Aborting)
return 0;
if(se == NULL)
{
if (se == NULL) {
hostaddr.sin_port = htons(80);
}
else
{
} else {
hostaddr.sin_port = se->s_port;
}
hostaddr.sin_family = AF_INET;
//ip = htonl(ip);
memcpy(&hostaddr.sin_addr,&ip,4);
// ip = htonl(ip);
memcpy(&hostaddr.sin_addr, &ip, 4);
if(m_ProxyEnabled)
{
//This is on a proxy, so we need to make sure to connect to the proxy machine
if (m_ProxyEnabled) {
// This is on a proxy, so we need to make sure to connect to the proxy machine
ip = inet_addr((const char *)m_ProxyIP);
if(ip==INADDR_NONE)
{
http_Asyncgethostbyname(&ip,NW_AGHBN_LOOKUP,m_ProxyIP);
if (ip == INADDR_NONE) {
http_Asyncgethostbyname(&ip, NW_AGHBN_LOOKUP, m_ProxyIP);
rcode = 0;
do
{
if(m_Aborting)
{
http_Asyncgethostbyname(&ip,NW_AGHBN_CANCEL,m_ProxyIP);
do {
if (m_Aborting) {
http_Asyncgethostbyname(&ip, NW_AGHBN_CANCEL, m_ProxyIP);
return 0;
}
rcode = http_Asyncgethostbyname(&ip,NW_AGHBN_READ,m_ProxyIP);
}while(rcode==0);
rcode = http_Asyncgethostbyname(&ip, NW_AGHBN_READ, m_ProxyIP);
} while (rcode == 0);
if(rcode == -1)
{
if (rcode == -1) {
m_State = HTTP_STATE_HOST_NOT_FOUND;
return 0;
}
}
//Use either the proxy port or 80 if none specified
hostaddr.sin_port = htons(m_ProxyPort?m_ProxyPort:80);
//Copy the proxy address...
memcpy(&hostaddr.sin_addr,&ip,4);
// Use either the proxy port or 80 if none specified
hostaddr.sin_port = htons(m_ProxyPort ? m_ProxyPort : 80);
// Copy the proxy address...
memcpy(&hostaddr.sin_addr, &ip, 4);
}
//Now we will connect to the host
// Now we will connect to the host
fd_set wfds;
timeval timeout;
@@ -559,36 +483,32 @@ int ChttpGet::ConnectSocket()
timeout.tv_usec = 0;
int serr = connect(m_DataSock, (SOCKADDR *)&hostaddr, sizeof(SOCKADDR));
int cerr = WSAGetLastError();
if(serr)
{
#ifdef __LINUX__
while((cerr==WSAEALREADY)||(cerr==WSAEINVAL)||(cerr==WSAEWOULDBLOCK)||(cerr==EINPROGRESS))
#else
while((cerr==WSAEALREADY)||(cerr==WSAEINVAL)||(cerr==WSAEWOULDBLOCK))
#endif
if (serr) {
#ifdef __LINUX__
while ((cerr == WSAEALREADY) || (cerr == WSAEINVAL) || (cerr == WSAEWOULDBLOCK) || (cerr == EINPROGRESS))
#else
while ((cerr == WSAEALREADY) || (cerr == WSAEINVAL) || (cerr == WSAEWOULDBLOCK))
#endif
{
FD_ZERO(&wfds);
FD_SET( m_DataSock, &wfds );
if(select(m_DataSock+1,NULL,&wfds,NULL,&timeout))
{
FD_SET(m_DataSock, &wfds);
if (select(m_DataSock + 1, NULL, &wfds, NULL, &timeout)) {
serr = 0;
break;
}
if(m_Aborting)
if (m_Aborting)
return 0;
serr = connect(m_DataSock, (SOCKADDR *)&hostaddr, sizeof(SOCKADDR));
if(serr == 0)
if (serr == 0)
break;
cerr = WSAGetLastError();
if(cerr==WSAEISCONN)
{
if (cerr == WSAEISCONN) {
serr = 0;
break;
}
};
}
if(serr)
{
if (serr) {
m_State = HTTP_STATE_CANT_CONNECT;
return 0;
}
@@ -596,86 +516,68 @@ int ChttpGet::ConnectSocket()
return 1;
}
char *ChttpGet::GetHTTPLine()
{
char *ChttpGet::GetHTTPLine() {
uint32_t iBytesRead;
char chunk[2];
uint32_t igotcrlf = 0;
memset(recv_buffer,0,1000);
do
{
chunk[0]='\0';
memset(recv_buffer, 0, 1000);
do {
chunk[0] = '\0';
bool gotdata = false;
do
{
iBytesRead = recv(m_DataSock,chunk,1,0);
do {
iBytesRead = recv(m_DataSock, chunk, 1, 0);
if(SOCKET_ERROR == iBytesRead)
{
if (SOCKET_ERROR == iBytesRead) {
int error = WSAGetLastError();
#ifdef __LINUX__
if(WSAEWOULDBLOCK==error || 0==error)
#else
if(WSAEWOULDBLOCK==error)
#endif
#ifdef __LINUX__
if (WSAEWOULDBLOCK == error || 0 == error)
#else
if (WSAEWOULDBLOCK == error)
#endif
{
gotdata = false;
continue;
}
else
{
} else {
return NULL;
}
}
else
{
} else {
gotdata = true;
}
}while(!gotdata);
} while (!gotdata);
if(chunk[0]==0x0d)
{
//This should always read a 0x0a
do
{
iBytesRead = recv(m_DataSock,chunk,1,0);
if (chunk[0] == 0x0d) {
// This should always read a 0x0a
do {
iBytesRead = recv(m_DataSock, chunk, 1, 0);
if(SOCKET_ERROR == iBytesRead)
{
if (SOCKET_ERROR == iBytesRead) {
int error = WSAGetLastError();
#ifdef __LINUX__
if(WSAEWOULDBLOCK==error || 0==error)
#else
if(WSAEWOULDBLOCK==error)
#endif
#ifdef __LINUX__
if (WSAEWOULDBLOCK == error || 0 == error)
#else
if (WSAEWOULDBLOCK == error)
#endif
{
gotdata = false;
continue;
}
else
{
} else {
return NULL;
}
}
else
{
} else {
gotdata = true;
}
}while(!gotdata);
} while (!gotdata);
igotcrlf = 1;
}
else
{ chunk[1] = '\0';
strcat(recv_buffer,chunk);
} else {
chunk[1] = '\0';
strcat(recv_buffer, chunk);
}
}while(igotcrlf==0);
} while (igotcrlf == 0);
return recv_buffer;
}
uint32_t ChttpGet::ReadDataChannel()
{
uint32_t ChttpGet::ReadDataChannel() {
char sDataBuffer[4096]; // Data-storage buffer for the data channel
int nBytesRecv; // Bytes received from the data channel
@@ -686,68 +588,58 @@ uint32_t ChttpGet::ReadDataChannel()
timeout.tv_usec = 500;
m_State = HTTP_STATE_RECEIVING;
do
{
do {
FD_ZERO(&wfds);
FD_SET( m_DataSock, &wfds );
FD_SET(m_DataSock, &wfds);
if((m_iBytesTotal)&&(m_iBytesIn==m_iBytesTotal))
{
if ((m_iBytesTotal) && (m_iBytesIn == m_iBytesTotal)) {
break;
}
select(m_DataSock+1,&wfds,NULL,NULL,&timeout);
select(m_DataSock + 1, &wfds, NULL, NULL, &timeout);
if(m_Aborting)
{
if (m_Aborting) {
fclose(LOCALFILE);
return 0;
}
nBytesRecv = recv(m_DataSock, (char *)&sDataBuffer,sizeof(sDataBuffer), 0);
nBytesRecv = recv(m_DataSock, (char *)&sDataBuffer, sizeof(sDataBuffer), 0);
if(m_Aborting)
{
if (m_Aborting) {
fclose(LOCALFILE);
return 0;
}
if(SOCKET_ERROR == nBytesRecv)
{
if (SOCKET_ERROR == nBytesRecv) {
int error = WSAGetLastError();
#ifdef __LINUX__
if(WSAEWOULDBLOCK==error || 0==error)
#else
if(WSAEWOULDBLOCK==error)
#endif
#ifdef __LINUX__
if (WSAEWOULDBLOCK == error || 0 == error)
#else
if (WSAEWOULDBLOCK == error)
#endif
{
nBytesRecv = 1;
continue;
}
}
m_iBytesIn += nBytesRecv;
if (nBytesRecv > 0 )
{
fwrite(sDataBuffer,nBytesRecv,1,LOCALFILE);
//Write sDataBuffer, nBytesRecv
if (nBytesRecv > 0) {
fwrite(sDataBuffer, nBytesRecv, 1, LOCALFILE);
// Write sDataBuffer, nBytesRecv
}
}while (nBytesRecv > 0);
} while (nBytesRecv > 0);
fclose(LOCALFILE);
// Close the file and check for error returns.
if (nBytesRecv == SOCKET_ERROR)
{
//Ok, we got a socket error -- xfer aborted?
if (nBytesRecv == SOCKET_ERROR) {
// Ok, we got a socket error -- xfer aborted?
m_State = HTTP_STATE_RECV_FAILED;
return 0;
}
else
{
//OutputDebugString("HTTP File complete!\n");
//done!
} else {
// OutputDebugString("HTTP File complete!\n");
// done!
m_State = HTTP_STATE_FILE_RECEIVED;
return 1;
}
@@ -762,17 +654,15 @@ void __cdecl http_gethostbynameworker(void *parm);
void *http_gethostbynameworker(void *parm);
#endif
int http_Asyncgethostbyname(uint32_t *ip,int command, char *hostname)
{
int http_Asyncgethostbyname(uint32_t *ip, int command, char *hostname) {
if(command==NW_AGHBN_LOOKUP)
{
if(http_lastaslu)
if (command == NW_AGHBN_LOOKUP) {
if (http_lastaslu)
http_lastaslu->abort = true;
async_dns_lookup *newaslu;
newaslu = (async_dns_lookup *)mem_malloc(sizeof(async_dns_lookup));
memset(&newaslu->ip,0,sizeof(uint32_t));
memset(&newaslu->ip, 0, sizeof(uint32_t));
newaslu->host = hostname;
newaslu->done = false;
newaslu->error = false;
@@ -781,45 +671,36 @@ int http_Asyncgethostbyname(uint32_t *ip,int command, char *hostname)
httpaslu.done = false;
#ifdef WIN32
_beginthread(http_gethostbynameworker,0,newaslu);
_beginthread(http_gethostbynameworker, 0, newaslu);
#elif defined(__LINUX__)
pthread_t thread;
if(!inet_LoadThreadLib())
{
if (!inet_LoadThreadLib()) {
return 0;
}
df_pthread_create(&thread,NULL,http_gethostbynameworker,newaslu);
df_pthread_create(&thread, NULL, http_gethostbynameworker, newaslu);
#endif
return 1;
}
else if(command==NW_AGHBN_CANCEL)
{
if(http_lastaslu)
} else if (command == NW_AGHBN_CANCEL) {
if (http_lastaslu)
http_lastaslu->abort = true;
http_lastaslu = NULL;
}
else if(command==NW_AGHBN_READ)
{
if(!http_lastaslu)
} else if (command == NW_AGHBN_READ) {
if (!http_lastaslu)
return -1;
if(httpaslu.done)
{
//free(http_lastaslu);
if (httpaslu.done) {
// free(http_lastaslu);
http_lastaslu = NULL;
memcpy(ip,&httpaslu.ip,sizeof(uint32_t));
memcpy(ip, &httpaslu.ip, sizeof(uint32_t));
return 1;
}
else if(httpaslu.error)
{
} else if (httpaslu.error) {
mem_free(http_lastaslu);
http_lastaslu = NULL;
return -1;
}
else return 0;
} else
return 0;
}
return -2;
}
// This is the worker thread which does the lookup.
@@ -834,20 +715,17 @@ void *http_gethostbynameworker(void *parm)
#endif
async_dns_lookup *lookup = (async_dns_lookup *)parm;
HOSTENT *he = gethostbyname(lookup->host);
if(he==NULL)
{
if (he == NULL) {
lookup->error = true;
#ifdef __LINUX__
#ifdef __LINUX__
return NULL;
#else
#else
return;
#endif
}
else if(!lookup->abort)
{
memcpy(&lookup->ip,he->h_addr_list[0],sizeof(uint32_t));
#endif
} else if (!lookup->abort) {
memcpy(&lookup->ip, he->h_addr_list[0], sizeof(uint32_t));
lookup->done = true;
memcpy(&httpaslu,lookup,sizeof(async_dns_lookup));
memcpy(&httpaslu, lookup, sizeof(async_dns_lookup));
}
mem_free(lookup);

View File

@@ -90,33 +90,29 @@
extern char *Proxy_server;
extern int16_t Proxy_port;
#ifdef __LINUX__
pthread_create_fp df_pthread_create = NULL;
pthread_exit_fp df_pthread_exit = NULL;
pthread_detach_fp df_pthread_detach = NULL;
pthread_self_fp df_pthread_self = NULL;
bool inet_LoadThreadLib(void)
{
if(df_pthread_create)
bool inet_LoadThreadLib(void) {
if (df_pthread_create)
return true;
void *lib;
lib = dlopen("libpthread.so",RTLD_GLOBAL|RTLD_NOW);
if(!lib)
{
lib = dlopen("libpthread.so", RTLD_GLOBAL | RTLD_NOW);
if (!lib) {
return false;
}
df_pthread_create = (pthread_create_fp)dlsym(lib,"pthread_create");
df_pthread_detach = (pthread_detach_fp)dlsym(lib,"pthread_detach");
df_pthread_self = (pthread_self_fp)dlsym(lib,"pthread_self");
df_pthread_create = (pthread_create_fp)dlsym(lib, "pthread_create");
df_pthread_detach = (pthread_detach_fp)dlsym(lib, "pthread_detach");
df_pthread_self = (pthread_self_fp)dlsym(lib, "pthread_self");
if(!df_pthread_create || !df_pthread_detach || !df_pthread_self)
{
df_pthread_create = NULL; //this variable I use to see if the library is loaded
if (!df_pthread_create || !df_pthread_detach || !df_pthread_self) {
df_pthread_create = NULL; // this variable I use to see if the library is loaded
return false;
}
@@ -126,195 +122,142 @@ bool inet_LoadThreadLib(void)
}
#endif
void InetGetFile::AbortGet()
{
if(m_bUseHTTP)
{
void InetGetFile::AbortGet() {
if (m_bUseHTTP) {
http->AbortGet();
}
else
{
} else {
ftp->AbortGet();
}
}
InetGetFile::InetGetFile(char *URL,char *localfile,char *proxyip,int16_t proxyport)
{
InetGetFile::InetGetFile(char *URL, char *localfile, char *proxyip, int16_t proxyport) {
m_HardError = 0;
http=NULL;
ftp=NULL;
if((URL==NULL)||(localfile==NULL))
{
http = NULL;
ftp = NULL;
if ((URL == NULL) || (localfile == NULL)) {
m_HardError = INET_ERROR_BADPARMS;
}
if(strstr(URL,"http:"))
{
if (strstr(URL, "http:")) {
m_bUseHTTP = true;
http = new ChttpGet(URL,localfile,proxyip,proxyport);
if(http==NULL)
http = new ChttpGet(URL, localfile, proxyip, proxyport);
if (http == NULL)
m_HardError = INET_ERROR_NO_MEMORY;
}
else if(strstr(URL,"ftp:"))
{
} else if (strstr(URL, "ftp:")) {
m_bUseHTTP = false;
ftp = new CFtpGet(URL,localfile);
if(ftp==NULL)
ftp = new CFtpGet(URL, localfile);
if (ftp == NULL)
m_HardError = INET_ERROR_NO_MEMORY;
}
else if(strstr(URL,"HTTP:"))
{
} else if (strstr(URL, "HTTP:")) {
m_bUseHTTP = true;
http = new ChttpGet(URL,localfile,proxyip,proxyport);
if(http==NULL)
http = new ChttpGet(URL, localfile, proxyip, proxyport);
if (http == NULL)
m_HardError = INET_ERROR_NO_MEMORY;
}
else if(strstr(URL,"FTP:"))
{
} else if (strstr(URL, "FTP:")) {
m_bUseHTTP = false;
ftp = new CFtpGet(URL,localfile);
if(ftp==NULL)
ftp = new CFtpGet(URL, localfile);
if (ftp == NULL)
m_HardError = INET_ERROR_NO_MEMORY;
}
else
{
} else {
m_HardError = INET_ERROR_CANT_PARSE_URL;
}
Sleep(1000);
}
InetGetFile::InetGetFile(char *URL,char *localfile)
{
InetGetFile::InetGetFile(char *URL, char *localfile) {
m_HardError = 0;
http=NULL;
ftp=NULL;
if((URL==NULL)||(localfile==NULL))
{
http = NULL;
ftp = NULL;
if ((URL == NULL) || (localfile == NULL)) {
m_HardError = INET_ERROR_BADPARMS;
}
if(strstr(URL,"http:"))
{
if (strstr(URL, "http:")) {
m_bUseHTTP = true;
http = new ChttpGet(URL,localfile);
if(http==NULL)
http = new ChttpGet(URL, localfile);
if (http == NULL)
m_HardError = INET_ERROR_NO_MEMORY;
}
else if(strstr(URL,"ftp:"))
{
} else if (strstr(URL, "ftp:")) {
m_bUseHTTP = false;
ftp = new CFtpGet(URL,localfile);
if(ftp==NULL)
ftp = new CFtpGet(URL, localfile);
if (ftp == NULL)
m_HardError = INET_ERROR_NO_MEMORY;
}
else if(strstr(URL,"HTTP:"))
{
} else if (strstr(URL, "HTTP:")) {
m_bUseHTTP = true;
http = new ChttpGet(URL,localfile);
if(http==NULL)
http = new ChttpGet(URL, localfile);
if (http == NULL)
m_HardError = INET_ERROR_NO_MEMORY;
}
else if(strstr(URL,"FTP:"))
{
} else if (strstr(URL, "FTP:")) {
m_bUseHTTP = false;
ftp = new CFtpGet(URL,localfile);
if(ftp==NULL)
ftp = new CFtpGet(URL, localfile);
if (ftp == NULL)
m_HardError = INET_ERROR_NO_MEMORY;
}
else
{
} else {
m_HardError = INET_ERROR_CANT_PARSE_URL;
}
Sleep(1000);
}
InetGetFile::~InetGetFile()
{
if(http!=NULL) delete http;
if(ftp!=NULL) delete ftp;
InetGetFile::~InetGetFile() {
if (http != NULL)
delete http;
if (ftp != NULL)
delete ftp;
}
BOOL InetGetFile::IsConnecting()
{
BOOL InetGetFile::IsConnecting() {
int state;
if(m_bUseHTTP)
{
if (m_bUseHTTP) {
state = http->GetStatus();
}
else if(ftp)
{
} else if (ftp) {
state = ftp->GetStatus();
}
else
{
} else {
return false;
}
if(state == FTP_STATE_CONNECTING)
{
if (state == FTP_STATE_CONNECTING) {
return true;
}
else
{
} else {
return false;
}
}
BOOL InetGetFile::IsReceiving()
{
BOOL InetGetFile::IsReceiving() {
int state;
if(m_bUseHTTP)
{
if (m_bUseHTTP) {
state = http->GetStatus();
}
else if(ftp)
{
} else if (ftp) {
state = ftp->GetStatus();
}
if(state == FTP_STATE_RECEIVING)
{
if (state == FTP_STATE_RECEIVING) {
return true;
}
else
{
} else {
return false;
}
}
BOOL InetGetFile::IsFileReceived()
{
BOOL InetGetFile::IsFileReceived() {
int state;
if(m_bUseHTTP)
{
if (m_bUseHTTP) {
state = http->GetStatus();
}
else if(ftp)
{
} else if (ftp) {
state = ftp->GetStatus();
}
if(state == FTP_STATE_FILE_RECEIVED)
{
if (state == FTP_STATE_FILE_RECEIVED) {
return true;
}
else
{
} else {
return false;
}
}
BOOL InetGetFile::IsFileError()
{
BOOL InetGetFile::IsFileError() {
int state;
if(m_HardError) return true;
if(m_bUseHTTP)
{
if (m_HardError)
return true;
if (m_bUseHTTP) {
state = http->GetStatus();
}
else if(ftp)
{
} else if (ftp) {
state = ftp->GetStatus();
}
switch(state)
{
switch (state) {
case FTP_STATE_URL_PARSING_ERROR:
case FTP_STATE_HOST_NOT_FOUND:
@@ -335,20 +278,16 @@ BOOL InetGetFile::IsFileError()
}
}
int InetGetFile::GetErrorCode()
{
int InetGetFile::GetErrorCode() {
int state;
if(m_HardError) return m_HardError;
if(m_bUseHTTP)
{
if (m_HardError)
return m_HardError;
if (m_bUseHTTP) {
state = http->GetStatus();
}
else if(ftp)
{
} else if (ftp) {
state = ftp->GetStatus();
}
switch(state)
{
switch (state) {
case FTP_STATE_URL_PARSING_ERROR:
return INET_ERROR_CANT_PARSE_URL;
@@ -356,7 +295,6 @@ int InetGetFile::GetErrorCode()
case FTP_STATE_HOST_NOT_FOUND:
return INET_ERROR_HOST_NOT_FOUND;
case FTP_STATE_DIRECTORY_INVALID:
case FTP_STATE_FILE_NOT_FOUND:
return INET_ERROR_BAD_FILE_OR_DIR;
@@ -377,28 +315,20 @@ int InetGetFile::GetErrorCode()
}
}
int InetGetFile::GetTotalBytes()
{
if(m_bUseHTTP)
{
int InetGetFile::GetTotalBytes() {
if (m_bUseHTTP) {
return http->GetTotalBytes();
}
else if(ftp)
{
} else if (ftp) {
return ftp->GetTotalBytes();
}
else return 0;
} else
return 0;
}
int InetGetFile::GetBytesIn()
{
if(m_bUseHTTP)
{
int InetGetFile::GetBytesIn() {
if (m_bUseHTTP) {
return http->GetBytesIn();
}
else if(ftp)
{
} else if (ftp) {
return ftp->GetBytesIn();
}
else return 0;
} else
return 0;
}

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <stdio.h>
@@ -23,79 +23,50 @@
#include "CFtp.h"
#include "Chttpget.h"
InetGetFile::InetGetFile(char *URL, char *localfile) {}
InetGetFile::InetGetFile(char *URL,char *localfile)
{
}
InetGetFile::~InetGetFile() {}
InetGetFile::~InetGetFile()
{
}
BOOL InetGetFile::IsFileReceived() { return false; }
BOOL InetGetFile::IsFileError() { return true; }
BOOL InetGetFile::IsFileReceived()
{
return false;
}
BOOL InetGetFile::IsFileError()
{
return true;
}
BOOL InetGetFile::IsConnecting() { return true; }
BOOL InetGetFile::IsConnecting()
{
return true;
}
BOOL InetGetFile::IsReceiving() { return false; }
BOOL InetGetFile::IsReceiving()
{
return false;
}
int InetGetFile::GetErrorCode() { return 0; }
int InetGetFile::GetErrorCode()
{
return 0;
}
int InetGetFile::GetBytesIn() { return 0; }
int InetGetFile::GetBytesIn()
{
return 0;
}
int InetGetFile::GetTotalBytes() { return 0; }
int InetGetFile::GetTotalBytes()
{
return 0;
}
void InetGetFile::AbortGet()
{
}
void InetGetFile::AbortGet() {}
////////////////////////////////////////////////////////////////////
CFtpGet::CFtpGet(char *URL,char *localfile,char *Username,char *Password){}
CFtpGet::~CFtpGet(){}
int CFtpGet::GetStatus(){return 0;}
uint32_t CFtpGet::GetBytesIn(){return 0;}
uint32_t CFtpGet::GetTotalBytes(){return 0;}
void CFtpGet::AbortGet(){}
void CFtpGet::WorkerThread(){}
int CFtpGet::ConnectControlSocket(){return 0;}
int CFtpGet::LoginHost(){return 0;}
uint32_t CFtpGet::SendFTPCommand(char *command){return 0;}
uint32_t CFtpGet::ReadFTPServerReply(){return 0;}
uint32_t CFtpGet::GetFile(){return 0;}
uint32_t CFtpGet::IssuePort(){return 0;}
uint32_t CFtpGet::ReadDataChannel(){return 0;}
void CFtpGet::FlushControlChannel(){}
CFtpGet::CFtpGet(char *URL, char *localfile, char *Username, char *Password) {}
CFtpGet::~CFtpGet() {}
int CFtpGet::GetStatus() { return 0; }
uint32_t CFtpGet::GetBytesIn() { return 0; }
uint32_t CFtpGet::GetTotalBytes() { return 0; }
void CFtpGet::AbortGet() {}
void CFtpGet::WorkerThread() {}
int CFtpGet::ConnectControlSocket() { return 0; }
int CFtpGet::LoginHost() { return 0; }
uint32_t CFtpGet::SendFTPCommand(char *command) { return 0; }
uint32_t CFtpGet::ReadFTPServerReply() { return 0; }
uint32_t CFtpGet::GetFile() { return 0; }
uint32_t CFtpGet::IssuePort() { return 0; }
uint32_t CFtpGet::ReadDataChannel() { return 0; }
void CFtpGet::FlushControlChannel() {}
/////////////////////////////////////////////////////////////////////
ChttpGet::ChttpGet(char *URL,char *localfile){}
ChttpGet::~ChttpGet(){}
int ChttpGet::GetStatus(){return 0;}
uint32_t ChttpGet::GetBytesIn(){return 0;}
uint32_t GetTotalBytes(){return 0;}
void AbortGet(){}
void WorkerThread(){}
int ConnectSocket(){return 0;}
char *GetHTTPLine(){return "ERR";}
uint32_t ReadDataChannel(){return 0;}
ChttpGet::ChttpGet(char *URL, char *localfile) {}
ChttpGet::~ChttpGet() {}
int ChttpGet::GetStatus() { return 0; }
uint32_t ChttpGet::GetBytesIn() { return 0; }
uint32_t GetTotalBytes() { return 0; }
void AbortGet() {}
void WorkerThread() {}
int ConnectSocket() { return 0; }
char *GetHTTPLine() { return "ERR"; }
uint32_t ReadDataChannel() { return 0; }

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// InsSongDlg.cpp : implementation file
//
@@ -32,54 +32,43 @@ static char THIS_FILE[] = __FILE__;
/////////////////////////////////////////////////////////////////////////////
// CInsSongDlg dialog
CInsSongDlg::CInsSongDlg(CWnd* pParent /*=NULL*/)
: CDialog(CInsSongDlg::IDD, pParent)
{
CInsSongDlg::CInsSongDlg(CWnd *pParent /*=NULL*/) : CDialog(CInsSongDlg::IDD, pParent) {
//{{AFX_DATA_INIT(CInsSongDlg)
m_SongPath = _T("");
//}}AFX_DATA_INIT
}
void CInsSongDlg::DoDataExchange(CDataExchange* pDX)
{
void CInsSongDlg::DoDataExchange(CDataExchange *pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CInsSongDlg)
DDX_Text(pDX, IDC_EDIT, m_SongPath);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CInsSongDlg, CDialog)
//{{AFX_MSG_MAP(CInsSongDlg)
ON_BN_CLICKED(IDC_BROWSE, OnBrowse)
//}}AFX_MSG_MAP
//{{AFX_MSG_MAP(CInsSongDlg)
ON_BN_CLICKED(IDC_BROWSE, OnBrowse)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CInsSongDlg message handlers
BOOL CInsSongDlg::OnInitDialog()
{
BOOL CInsSongDlg::OnInitDialog() {
CDialog::OnInitDialog();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CInsSongDlg::OnBrowse()
{
void CInsSongDlg::OnBrowse() {
CFileDialog opendlg(TRUE, "osf", NULL, OFN_PATHMUSTEXIST, "Outrage Stream Files(*.osf)|*.osf||", this);
CEdit *edit = (CEdit *)GetDlgItem(IDC_EDIT);
// get filename to play
// get filename to play
if (opendlg.DoModal() != IDOK) {
return;
}
edit->SetWindowText((LPCTSTR)opendlg.GetPathName());
}

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#if !defined(AFX_INSSONGDLG_H__B4518671_1FF8_11D2_B2B3_00A0C94B8467__INCLUDED_)
#define AFX_INSSONGDLG_H__B4518671_1FF8_11D2_B2B3_00A0C94B8467__INCLUDED_
@@ -28,29 +28,26 @@
/////////////////////////////////////////////////////////////////////////////
// CInsSongDlg dialog
class CInsSongDlg : public CDialog
{
// Construction
class CInsSongDlg : public CDialog {
// Construction
public:
CInsSongDlg(CWnd* pParent = NULL); // standard constructor
CInsSongDlg(CWnd *pParent = NULL); // standard constructor
// Dialog Data
// Dialog Data
//{{AFX_DATA(CInsSongDlg)
enum { IDD = IDD_INSERT_SONG };
CString m_SongPath;
//}}AFX_DATA
// Overrides
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CInsSongDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
protected:
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CInsSongDlg)
afx_msg void OnBrowse();

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// PlaySongDlg.cpp : implementation file
//
@@ -34,48 +34,39 @@ static char THIS_FILE[] = __FILE__;
/////////////////////////////////////////////////////////////////////////////
// CPlaySongDlg dialog
CPlaySongDlg::CPlaySongDlg(CWnd* pParent /*=NULL*/)
: CDialog(CPlaySongDlg::IDD, pParent)
{
CPlaySongDlg::CPlaySongDlg(CWnd *pParent /*=NULL*/) : CDialog(CPlaySongDlg::IDD, pParent) {
//{{AFX_DATA_INIT(CPlaySongDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CPlaySongDlg::DoDataExchange(CDataExchange* pDX)
{
void CPlaySongDlg::DoDataExchange(CDataExchange *pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPlaySongDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPlaySongDlg, CDialog)
//{{AFX_MSG_MAP(CPlaySongDlg)
ON_WM_TIMER()
ON_WM_DESTROY()
//}}AFX_MSG_MAP
//{{AFX_MSG_MAP(CPlaySongDlg)
ON_WM_TIMER()
ON_WM_DESTROY()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPlaySongDlg message handlers
BOOL CPlaySongDlg::OnInitDialog()
{
BOOL CPlaySongDlg::OnInitDialog() {
CDialog::OnInitDialog();
// set up stream to play.
// set up stream to play.
m_Stream.Open((LPCTSTR)m_StreamName);
SetTimer(0, 100, NULL);
// okay we should start playing the song
// okay we should start playing the song
CProgressCtrl *progress = (CProgressCtrl *)GetDlgItem(IDC_PLAYPROGRESS);
progress->SetRange(0, m_Stream.GetLength()/1024);
progress->SetRange(0, m_Stream.GetLength() / 1024);
m_Stream.Play();
@@ -83,16 +74,14 @@ BOOL CPlaySongDlg::OnInitDialog()
// EXCEPTION: OCX Property Pages should return FALSE
}
void CPlaySongDlg::OnTimer(UINT nIDEvent)
{
void CPlaySongDlg::OnTimer(UINT nIDEvent) {
CProgressCtrl *progress = (CProgressCtrl *)GetDlgItem(IDC_PLAYPROGRESS);
CStatic *text = (CStatic *)GetDlgItem(IDC_STATUS_TEXT);
char buf[80];
sprintf(buf, "%s (%d%%)", (LPCTSTR)m_StreamName, m_Stream.GetPos()*100/m_Stream.GetLength());
sprintf(buf, "%s (%d%%)", (LPCTSTR)m_StreamName, m_Stream.GetPos() * 100 / m_Stream.GetLength());
text->SetWindowText(buf);
progress->SetPos(m_Stream.GetPos()/1024);
progress->SetPos(m_Stream.GetPos() / 1024);
MusicPlayFrame();
@@ -103,9 +92,7 @@ void CPlaySongDlg::OnTimer(UINT nIDEvent)
CDialog::OnTimer(nIDEvent);
}
void CPlaySongDlg::OnDestroy()
{
void CPlaySongDlg::OnDestroy() {
CDialog::OnDestroy();
KillTimer(0);

View File

@@ -1,20 +1,20 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#if !defined(AFX_PLAYSONGDLG_H__932821D1_1D86_11D2_B2B3_00A0C94B8467__INCLUDED_)
#define AFX_PLAYSONGDLG_H__932821D1_1D86_11D2_B2B3_00A0C94B8467__INCLUDED_
@@ -30,32 +30,28 @@
/////////////////////////////////////////////////////////////////////////////
// CPlaySongDlg dialog
class CPlaySongDlg : public CDialog
{
// Construction
class CPlaySongDlg : public CDialog {
// Construction
public:
AudioStream m_Stream;
CString m_StreamName;
CPlaySongDlg(CWnd* pParent = NULL); // standard constructor
CPlaySongDlg(CWnd *pParent = NULL); // standard constructor
// Dialog Data
// Dialog Data
//{{AFX_DATA(CPlaySongDlg)
enum { IDD = IDD_PLAYSONG };
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA
// Overrides
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CPlaySongDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
protected:
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CPlaySongDlg)
afx_msg void OnTimer(UINT nIDEvent);

Some files were not shown because too many files have changed in this diff Show More