diff --git a/backup.lst b/backup.lst index 9549ef36..01e91a8a 100644 --- a/backup.lst +++ b/backup.lst @@ -23,19 +23,21 @@ engine\ engine\client\ engine\server\ engine\common\ +engine\client\sound\ launch\ launch\imagelib\ launch\soundlib\ +launch\tools\ public\ launch\ mainui\ -snd_dx\ vid_gl\ utils\ utils\vgui\ +utils\vgui\include\ +utils\vgui\lib\win32_vc6\ utils\xwad\ utils\bsplib -utils\ripper utils\sprite\ utils\studio\ utils\ximage\ diff --git a/change.log b/change.log index 56dac585..21aedb73 100644 --- a/change.log +++ b/change.log @@ -1,8 +1,9 @@ build ???? +Tools: move all tools into launch.dll +Sound: moving snd_dx.dll into engine.dll Sound: implement CDAudio emulator with support mp3 tracks from original Half-Life Sound: implement mp3 support -Tools: renamed xtools.dll into utils.dll GameUI: GameUI.dll renamed to MainUI.dll to avoid conflict with original valve's GameUI.dll Engine: support for StartupVids.txt Engine: get full compatibility with hl.dll diff --git a/debug.bat b/debug.bat index 029ea7aa..8de78396 100644 --- a/debug.bat +++ b/debug.bat @@ -26,12 +26,6 @@ if errorlevel 1 set BUILD_ERROR=1 %MSDEV% vid_gl/vid_gl.dsp %CONFIG%"vid_gl - Win32 Debug" %build_target% if errorlevel 1 set BUILD_ERROR=1 -%MSDEV% snd_dx/snd_dx.dsp %CONFIG%"snd_dx - Win32 Debug" %build_target% -if errorlevel 1 set BUILD_ERROR=1 - -%MSDEV% utils/utils.dsp %CONFIG%"utils - Win32 Debug" %build_target% -if errorlevel 1 set BUILD_ERROR=1 - if "%BUILD_ERROR%"=="" goto build_ok echo ********************* @@ -58,8 +52,6 @@ if exist mainui\mainui.plg del /f /q mainui\mainui.plg if exist launch\launch.plg del /f /q launch\launch.plg if exist vid_gl\vid_gl.plg del /f /q vid_gl\vid_gl.plg if exist viewer\viewer.plg del /f /q viewer\viewer.plg -if exist snd_dx\snd_dx.plg del /f /q snd_dx\snd_dx.plg -if exist utils\utils.plg del /f /q utils\utils.plg echo echo Build succeeded! diff --git a/engine/client/cl_game.c b/engine/client/cl_game.c index 4ff2c2d1..f48aaf96 100644 --- a/engine/client/cl_game.c +++ b/engine/client/cl_game.c @@ -3697,7 +3697,7 @@ qboolean CL_LoadProgs( const char *name ) clgame.hInstance = FS_LoadLibrary( name, false ); if( !clgame.hInstance ) return false; - +Msg( "exports size %i\n", sizeof( HUD_FUNCTIONS )); // clear exports for( func = cdll_exports; func && func->name; func++ ) *func->func = NULL; diff --git a/engine/client/cl_menu.c b/engine/client/cl_menu.c index aaaf528f..267f1b6b 100644 --- a/engine/client/cl_menu.c +++ b/engine/client/cl_menu.c @@ -769,9 +769,10 @@ retuns list of valid audio renderers */ static char **pfnGetAudioList( int *numRenders ) { - if( numRenders ) - *numRenders = host.num_audio_dlls; - return host.audio_dlls; + static const char *sndlib = "default"; + + if( numRenders ) *numRenders = 1; + return &(char *)sndlib; } /* @@ -854,11 +855,6 @@ pfnChangeAudio */ static void pfnChangeAudio( const char *dllName ) { - if( !dllName || !*dllName ) return; - - // sound subsystem will be automatically restarted on nextframe - Cvar_FullSet( "host_audio", dllName, CVAR_INIT|CVAR_ARCHIVE ); - Cbuf_ExecuteText( EXEC_APPEND, "snd_restart\n" ); } /* diff --git a/engine/client/client.h b/engine/client/client.h index 802eefd3..535bc424 100644 --- a/engine/client/client.h +++ b/engine/client/client.h @@ -653,6 +653,25 @@ void Con_CharEvent( int key ); void Key_Console( int key ); void Con_Close( void ); +// +// sound.c +// +void S_StreamRawSamples( int samples, int rate, int width, int channels, const byte *data ); +void S_StartBackgroundTrack( const char *intro, const char *loop ); +void S_StopBackgroundTrack( void ); +void S_StreamSetPause( int pause ); +void S_StartStreaming( void ); +void S_StopStreaming( void ); +void S_BeginRegistration( void ); +sound_t S_RegisterSound( const char *sample ); +void S_EndRegistration( void ); +void S_StartSound( const vec3_t pos, int ent, int chan, sound_t sfx, float vol, float attn, int pitch, int flags ); +void S_AmbientSound( const vec3_t pos, int ent, int chan, sound_t handle, float fvol, float attn, int pitch, int flags ); +void S_FadeClientVolume( float fadePercent, float fadeOutSeconds, float holdTime, float fadeInSeconds ); +void S_StartLocalSound( const char *name ); +void S_RenderFrame( struct ref_params_s *fd ); +void S_ExtraUpdate( void ); + // // cl_menu.c // diff --git a/snd_dx/s_backend.c b/engine/client/sound/s_backend.c similarity index 94% rename from snd_dx/s_backend.c rename to engine/client/sound/s_backend.c index 60588946..5b518fde 100644 --- a/snd_dx/s_backend.c +++ b/engine/client/sound/s_backend.c @@ -4,6 +4,7 @@ //======================================================================= #include +#include "common.h" #include "sound.h" #define iDirectSoundCreate( a, b, c ) pDirectSoundCreate( a, b, c ) @@ -487,6 +488,9 @@ int SNDDMA_Init( void *hInst ) { si_state_t stat = SIS_FAILURE; // assume DirectSound won't initialize + // already initialized + if( dma.initialized ) return true; + Mem_Set( &dma, 0, sizeof( dma )); s_wavonly = Cvar_Get( "s_wavonly", "0", CVAR_LATCH_AUDIO|CVAR_ARCHIVE, "force to use WaveOutput only" ); @@ -539,6 +543,7 @@ int SNDDMA_Init( void *hInst ) return false; } + dma.initialized = true; snd_firsttime = false; return true; } @@ -723,6 +728,8 @@ Reset the sound device for exiting */ void SNDDMA_Shutdown( void ) { + if( !dma.initialized ) return; + dma.initialized = false; SNDDMA_FreeSound(); } @@ -748,6 +755,7 @@ between a deactivate and an activate. */ void S_Activate( qboolean active, void *hInst ) { + if( !dma.initialized ) return; snd_hwnd = (HWND)hInst; if( active ) diff --git a/snd_dx/s_dsp.c b/engine/client/sound/s_dsp.c similarity index 96% rename from snd_dx/s_dsp.c rename to engine/client/sound/s_dsp.c index c24e993e..0cef8d15 100644 --- a/snd_dx/s_dsp.c +++ b/engine/client/sound/s_dsp.c @@ -3,6 +3,7 @@ // s_dsp.c - digital signal processing algorithms for audio FX //======================================================================= +#include "common.h" #include "sound.h" #define SIGN( d ) (( d ) < 0 ? -1 : 1 ) diff --git a/snd_dx/s_load.c b/engine/client/sound/s_load.c similarity index 90% rename from snd_dx/s_load.c rename to engine/client/sound/s_load.c index 7c458696..8d3f6200 100644 --- a/snd_dx/s_load.c +++ b/engine/client/sound/s_load.c @@ -3,6 +3,7 @@ // s_load.c - sound managment //======================================================================= +#include "common.h" #include "sound.h" #include "byteorder.h" @@ -91,7 +92,7 @@ static wavdata_t *S_CreateDefaultSound( void ) { wavdata_t *sc; - sc = Z_Malloc( sizeof( wavdata_t )); + sc = Mem_Alloc( sndpool, sizeof( wavdata_t )); sc->width = 2; sc->channels = 1; @@ -99,7 +100,7 @@ static wavdata_t *S_CreateDefaultSound( void ) sc->rate = SOUND_DMA_SPEED; sc->samples = SOUND_DMA_SPEED; sc->size = sc->samples * sc->width * sc->channels; - sc->buffer = Z_Malloc( sc->size ); + sc->buffer = Mem_Alloc( sndpool, sc->size ); return sc; } @@ -142,7 +143,9 @@ sfx_t *S_FindName( const char *name, int *pfInCache ) sfx_t *sfx; uint hash; - if( !name || !name[0] ) return NULL; + if( !name || !name[0] || !dma.initialized ) + return NULL; + if( com.strlen( name ) >= MAX_STRING ) { MsgDev( D_ERROR, "S_FindSound: sound name too long: %s", name ); @@ -250,6 +253,8 @@ void S_EndRegistration( void ) sfx_t *sfx; int i; + if( !dma.initialized ) return; + // free any sounds not from this registration sequence for( i = 0, sfx = s_knownSfx; i < s_numSfx; i++, sfx++ ) { @@ -277,6 +282,8 @@ sound_t S_RegisterSound( const char *name ) { sfx_t *sfx; + if( !dma.initialized ) return 0; + if( S_TestSoundChar( name, '!' )) { com.strncpy( s_sentenceImmediateName, name, sizeof( s_sentenceImmediateName )); @@ -294,6 +301,9 @@ sound_t S_RegisterSound( const char *name ) sfx_t *S_GetSfxByHandle( sound_t handle ) { + if( !dma.initialized ) + return NULL; + if( handle == SENTENCE_INDEX ) { // create new sfx @@ -318,6 +328,9 @@ void S_FreeSounds( void ) sfx_t *sfx; int i; + if( !dma.initialized ) + return; + // stop all sounds S_StopAllSounds(); diff --git a/snd_dx/s_main.c b/engine/client/sound/s_main.c similarity index 92% rename from snd_dx/s_main.c rename to engine/client/sound/s_main.c index 5ddad41f..2c4f739d 100644 --- a/snd_dx/s_main.c +++ b/engine/client/sound/s_main.c @@ -3,8 +3,9 @@ // s_main.c - sound engine //======================================================================= +#include "common.h" #include "sound.h" -#include "const.h" +#include "client.h" #include "ref_params.h" #define SND_CLIP_DISTANCE 1000.0f @@ -58,7 +59,7 @@ S_FadeClientVolume */ void S_FadeClientVolume( float fadePercent, float fadeOutSeconds, float holdTime, float fadeInSeconds ) { - soundfade.starttime = si.GetServerTime(); + soundfade.starttime = cl.mtime[0]; soundfade.initial_percent = fadePercent; soundfade.fadeouttime = fadeOutSeconds; soundfade.holdtime = holdTime; @@ -112,7 +113,7 @@ void S_UpdateSoundFade( void ) totaltime = soundfade.fadeouttime + soundfade.fadeintime + soundfade.holdtime; - elapsed = si.GetServerTime() - soundfade.starttime; + elapsed = cl.mtime[0] - soundfade.starttime; // clock wrapped or reset (BUG) or we've gone far enough if( elapsed < 0.0f || elapsed >= totaltime || totaltime <= 0.0f ) @@ -354,7 +355,7 @@ void SND_Spatialize( channel_t *ch ) if( !ch->staticsound ) { - if( !si.GetEntitySpatialization( ch->entnum, ch->origin, NULL )) + if( !CL_GetEntitySpatialization( ch->entnum, ch->origin, NULL )) return; // entity not exist on client } @@ -404,6 +405,7 @@ void S_StartSound( const vec3_t pos, int ent, int chan, sound_t handle, float fv channel_t *target_chan, *check; int vol, ch_idx; + if( !dma.initialized ) return; sfx = S_GetSfxByHandle( handle ); if( !sfx ) return; @@ -515,7 +517,7 @@ void S_StartSound( const vec3_t pos, int ent, int chan, sound_t handle, float fv /* ================= -S_StartStaticSound +S_AmbientSound Start playback of a sound, loaded into the static portion of the channel array. Currently, this should be used for looping ambient sounds, looping sounds @@ -527,7 +529,7 @@ Pitch changes playback pitch of wave by % above or below 100. Ignored if pitch NOTE: volume is 0.0 - 1.0 and attenuation is 0.0 - 1.0 when passed in. ================= */ -void S_StaticSound( const vec3_t pos, int ent, int chan, sound_t handle, float fvol, float attn, int pitch, int flags ) +void S_AmbientSound( const vec3_t pos, int ent, int chan, sound_t handle, float fvol, float attn, int pitch, int flags ) { channel_t *ch; wavdata_t *pSource = NULL; @@ -536,6 +538,7 @@ void S_StaticSound( const vec3_t pos, int ent, int chan, sound_t handle, float f qboolean looping = false; vec3_t origin; + if( !dma.initialized ) return; sfx = S_GetSfxByHandle( handle ); if( !sfx ) return; @@ -556,7 +559,7 @@ void S_StaticSound( const vec3_t pos, int ent, int chan, sound_t handle, float f if( !pos ) pos = origin; - if( ent != 0 ) si.GetEntitySpatialization( ent, origin, NULL ); + if( ent != 0 ) CL_GetEntitySpatialization( ent, origin, NULL ); // pick a channel to play on from the static area ch = SND_PickStaticChannel( ent, sfx ); // autolooping sounds are always fixed origin(?) @@ -613,7 +616,8 @@ void S_StartLocalSound( const char *name ) { sound_t sfxHandle; int flags = (SND_LOCALSOUND|SND_STOP_LOOPING); - + + if( !dma.initialized ) return; sfxHandle = S_RegisterSound( name ); S_StartSound( NULL, s_listener.entnum, CHAN_AUTO, sfxHandle, VOL_NORM, ATTN_NONE, PITCH_NORM, flags ); } @@ -630,6 +634,9 @@ int S_GetCurrentStaticSounds( soundlist_t *pout, int size, int entchannel ) int sounds_left = size; int i; + if( !dma.initialized ) + return 0; + for( i = MAX_DYNAMIC_CHANNELS; i < total_channels && sounds_left; i++ ) { if(( !entchannel || channels[i].entchannel == entchannel ) && channels[i].sfx ) @@ -678,6 +685,7 @@ void S_StopSound( int entnum, int channel, const char *soundname ) { sfx_t *sfx; + if( !dma.initialized ) return; sfx = S_FindName( soundname, NULL ); S_AlterChannel( entnum, channel, sfx, 0, 0, SND_STOP ); } @@ -691,6 +699,7 @@ void S_StopAllSounds( void ) { int i; + if( !dma.initialized ) return; total_channels = MAX_DYNAMIC_CHANNELS; // no statics for( i = 0; i < MAX_CHANNELS; i++ ) @@ -751,6 +760,7 @@ Don't let sound skip if going slow */ void S_ExtraUpdate( void ) { + if( !dma.initialized ) return; S_UpdateChannels (); } @@ -766,6 +776,7 @@ void S_RenderFrame( ref_params_t *fd ) int i, total; channel_t *ch; + if( !dma.initialized ) return; if( !fd ) return; // too early // if the loading plaque is up, clear everything @@ -777,8 +788,8 @@ void S_RenderFrame( ref_params_t *fd ) s_listener.entnum = fd->viewentity; // can be camera entity too s_listener.frametime = fd->frametime; s_listener.waterlevel = fd->waterlevel; - s_listener.active = si.IsActive(); - s_listener.inmenu = si.IsInMenu(); + s_listener.active = CL_IsInGame(); + s_listener.inmenu = CL_IsInMenu(); s_listener.paused = fd->paused; VectorCopy( fd->vieworg, s_listener.origin ); @@ -915,6 +926,9 @@ S_Init */ qboolean S_Init( void *hInst ) { + if( FS_CheckParm( "-nosound" )) + return false; + Cmd_ExecuteString( "sndlatch\n" ); s_volume = Cvar_Get( "volume", "0.7", CVAR_ARCHIVE, "sound volume" ); @@ -957,6 +971,8 @@ qboolean S_Init( void *hInst ) // ======================================================================= void S_Shutdown( void ) { + if( !dma.initialized ) return; + Cmd_RemoveCommand( "play" ); Cmd_RemoveCommand( "stopsound" ); Cmd_RemoveCommand( "music" ); diff --git a/snd_dx/s_mix.c b/engine/client/sound/s_mix.c similarity index 96% rename from snd_dx/s_mix.c rename to engine/client/sound/s_mix.c index fce0e4db..e87a71c8 100644 --- a/snd_dx/s_mix.c +++ b/engine/client/sound/s_mix.c @@ -3,7 +3,9 @@ // s_mix.c - portable code to mix sounds //======================================================================= +#include "common.h" #include "sound.h" +#include "client.h" #include "byteorder.h" #define IPAINTBUFFER 0 @@ -596,7 +598,7 @@ void MIX_MixChannelsToPaintbuffer( int endtime, int rate, int outputRate ) ch->pitch = VOX_ModifyPitch( ch, ch->basePitch * 0.01f ); else ch->pitch = ch->basePitch * 0.01f; - if( si.GetClientEdict( ch->entnum ) && ( ch->entchannel == CHAN_VOICE )) + if( CL_GetEntityByIndex( ch->entnum ) && ( ch->entchannel == CHAN_VOICE )) { // UNDONE: implement SND_MoveMouth16 too SND_MoveMouth8( ch, pSource, sampleCount ); diff --git a/snd_dx/s_mouth.c b/engine/client/sound/s_mouth.c similarity index 85% rename from snd_dx/s_mouth.c rename to engine/client/sound/s_mouth.c index d85bcbe5..e9f5cbfb 100644 --- a/snd_dx/s_mouth.c +++ b/engine/client/sound/s_mouth.c @@ -3,7 +3,9 @@ // s_mouth.c - animate mouth //======================================================================= +#include "common.h" #include "sound.h" +#include "client.h" #include "const.h" #define CAVGSAMPLES 10 @@ -15,7 +17,7 @@ void SND_InitMouth( int entnum, int entchannel ) cl_entity_t *clientEntity; // init mouth movement vars - clientEntity = si.GetClientEdict( entnum ); + clientEntity = CL_GetEntityByIndex( entnum ); if( clientEntity ) { @@ -32,7 +34,7 @@ void SND_CloseMouth( channel_t *ch ) { cl_entity_t *clientEntity; - clientEntity = si.GetClientEdict( ch->entnum ); + clientEntity = CL_GetEntityByIndex( ch->entnum ); if( clientEntity ) { @@ -51,7 +53,7 @@ void SND_MoveMouth8( channel_t *ch, wavdata_t *pSource, int count ) int scount, pos = 0; uint i; - clientEntity = si.GetClientEdict( ch->entnum ); + clientEntity = CL_GetEntityByIndex( ch->entnum ); if( !clientEntity ) return; pMouth = &clientEntity->mouth; diff --git a/snd_dx/s_stream.c b/engine/client/sound/s_stream.c similarity index 91% rename from snd_dx/s_stream.c rename to engine/client/sound/s_stream.c index 7051bea3..4a71a869 100644 --- a/snd_dx/s_stream.c +++ b/engine/client/sound/s_stream.c @@ -3,7 +3,9 @@ // s_stream.c - sound streaming //======================================================================= +#include "common.h" #include "sound.h" +#include "client.h" #include "byteorder.h" portable_samplepair_t s_rawsamples[MAX_RAW_SAMPLES]; @@ -31,6 +33,7 @@ void S_StartBackgroundTrack( const char *introTrack, const char *mainTrack ) { S_StopBackgroundTrack(); + if( !dma.initialized ) return; if(( !introTrack || !*introTrack ) && ( !mainTrack || !*mainTrack )) return; @@ -50,6 +53,7 @@ void S_StopBackgroundTrack( void ) { s_listener.stream_paused = false; + if( !dma.initialized ) return; if( !s_bgTrack.stream ) return; FS_CloseStream( s_bgTrack.stream ); @@ -75,6 +79,7 @@ void S_StreamBackgroundTrack( void ) byte raw[MAX_RAW_SAMPLES]; int r, fileBytes; + if( !dma.initialized ) return; if( !s_bgTrack.stream ) return; if( s_listener.streaming ) return; // we are playing movie or somewhat @@ -147,6 +152,7 @@ S_StartStreaming */ void S_StartStreaming( void ) { + if( !dma.initialized ) return; // begin streaming movie soundtrack s_listener.streaming = true; s_listener.lerping = false; @@ -159,6 +165,7 @@ S_StopStreaming */ void S_StopStreaming( void ) { + if( !dma.initialized ) return; s_listener.streaming = false; s_listener.lerping = false; s_rawend = 0; @@ -176,6 +183,7 @@ void S_StreamSoundTrack( void ) byte raw[MAX_RAW_SAMPLES]; int r, fileBytes; + if( !dma.initialized ) return; if( !s_listener.streaming || s_listener.paused ) return; // see how many samples should be copied into the raw buffer @@ -184,7 +192,7 @@ void S_StreamSoundTrack( void ) while( s_rawend < soundtime + MAX_RAW_SAMPLES ) { - wavdata_t *info = si.GetMovieInfo(); + wavdata_t *info = SCR_GetMovieInfo(); bufferSamples = MAX_RAW_SAMPLES - (s_rawend - soundtime); @@ -201,7 +209,7 @@ void S_StreamSoundTrack( void ) } // read audio stream - r = si.GetAudioChunk( raw, fileBytes ); + r = SCR_GetAudioChunk( raw, fileBytes ); if( r < fileBytes ) { diff --git a/snd_dx/s_utils.c b/engine/client/sound/s_utils.c similarity index 95% rename from snd_dx/s_utils.c rename to engine/client/sound/s_utils.c index dbfe03e1..4dd795f1 100644 --- a/snd_dx/s_utils.c +++ b/engine/client/sound/s_utils.c @@ -3,6 +3,7 @@ // s_utils.c - common sound functions //======================================================================= +#include "common.h" #include "sound.h" // hardcoded macros to test for zero crossing diff --git a/snd_dx/s_vox.c b/engine/client/sound/s_vox.c similarity index 95% rename from snd_dx/s_vox.c rename to engine/client/sound/s_vox.c index efd9e16f..283d0c61 100644 --- a/snd_dx/s_vox.c +++ b/engine/client/sound/s_vox.c @@ -3,6 +3,7 @@ // s_vox.c - npc sentences //======================================================================= +#include "common.h" #include "sound.h" #include "const.h" diff --git a/snd_dx/sound.h b/engine/client/sound/sound.h similarity index 84% rename from snd_dx/sound.h rename to engine/client/sound/sound.h index 1ddb4217..ba23de3a 100644 --- a/snd_dx/sound.h +++ b/engine/client/sound/sound.h @@ -6,14 +6,6 @@ #ifndef SOUND_H #define SOUND_H -#include -#include "launch_api.h" -#include "engine_api.h" -#include "vsound_api.h" -#include "cl_entity.h" - -extern stdlib_api_t com; -extern vsound_imp_t si; extern byte *sndpool; #include "mathlib.h" @@ -99,6 +91,7 @@ typedef struct int samples; // mono samples in buffer int samplepos; // in mono samples byte *buffer; + qboolean initialized; // sound engine is active } dma_t; #include "vox.h" @@ -172,7 +165,6 @@ typedef struct ==================================================================== */ #define Host_Error com.error -#define Z_Malloc( size ) Mem_Alloc( sndpool, size ) // initializes cycling through a DMA buffer and returns information on it qboolean SNDDMA_Init( void *hInst ); @@ -216,7 +208,6 @@ void S_PrintDeviceName( void ); // s_main.c // void S_FreeChannel( channel_t *ch ); -void S_ExtraUpdate( void ); // // s_mix.c @@ -247,17 +238,11 @@ void S_Activate( qboolean active, void *hInst ); void S_SoundList_f( void ); void S_SoundInfo_f( void ); -// if origin is NULL, the sound will be dynamically sourced from the entity -void S_StartSound( const vec3_t pos, int ent, int chan, sound_t sfx, float vol, float attn, int pitch, int flags ); -void S_StaticSound( const vec3_t pos, int ent, int chan, sound_t handle, float fvol, float attn, int pitch, int flags ); channel_t *SND_PickDynamicChannel( int entnum, int channel, sfx_t *sfx ); channel_t *SND_PickStaticChannel( int entnum, sfx_t *sfx ); int S_GetCurrentStaticSounds( soundlist_t *pout, int size, int entchannel ); -void S_FadeClientVolume( float fadePercent, float fadeOutSeconds, float holdTime, float fadeInSeconds ); -void S_StartLocalSound( const char *name ); sfx_t *S_GetSfxByHandle( sound_t handle ); void S_StopSound( int entnum, int channel, const char *soundname ); -void S_RenderFrame( struct ref_params_s *fd ); void S_StopAllSounds( void ); void S_FreeSounds( void ); @@ -271,14 +256,8 @@ void SND_CloseMouth( channel_t *ch ); // // s_stream.c // -void S_StartStreaming( void ); -void S_StopStreaming( void ); void S_StreamSoundTrack( void ); -void S_StreamRawSamples( int samples, int rate, int width, int channels, const byte *data ); -void S_StartBackgroundTrack( const char *intro, const char *loop ); void S_StreamBackgroundTrack( void ); -void S_StopBackgroundTrack( void ); -void S_StreamSetPause( int pause ); // // s_utils.c @@ -299,8 +278,4 @@ void VOX_LoadSound( channel_t *pchan, const char *psz ); float VOX_ModifyPitch( channel_t *ch, float pitch ); int VOX_MixDataToDevice( channel_t *pChannel, int sampleCount, int outputRate, int outputOffset ); -void S_BeginRegistration( void ); -sound_t S_RegisterSound( const char *sample ); -void S_EndRegistration( void ); - #endif//SOUND_H \ No newline at end of file diff --git a/snd_dx/vox.h b/engine/client/sound/vox.h similarity index 100% rename from snd_dx/vox.h rename to engine/client/sound/vox.h diff --git a/engine/common/cm_model.c b/engine/common/cm_model.c index c9d9300c..e5a70825 100644 --- a/engine/common/cm_model.c +++ b/engine/common/cm_model.c @@ -671,7 +671,7 @@ static void BSP_LoadEntityString( dlump_t *l ) byte *in; in = (void *)(mod_base + l->fileofs); - loadmodel->entities = Mem_Alloc( loadmodel->mempool, l->filelen ); + loadmodel->entities = Mem_Alloc( loadmodel->mempool, l->filelen + 1 ); Mem_Copy( loadmodel->entities, mod_base + l->fileofs, l->filelen ); cm.entityscript = Com_OpenScript( "entities", in, l->filelen ); } diff --git a/engine/common/com_export.h b/engine/common/com_export.h index 4c4b98ef..72a5b9b5 100644 --- a/engine/common/com_export.h +++ b/engine/common/com_export.h @@ -5,65 +5,30 @@ #ifndef COM_EXPORT_H #define COM_EXPORT_H -#include "cm_local.h" - #ifdef __cplusplus extern "C" { #endif // linked interfaces extern stdlib_api_t com; -extern vsound_exp_t *se; extern render_exp_t *re; #ifdef __cplusplus } #endif -_inline int CL_CreateDecalList( decallist_t *pList, qboolean changelevel ) +typedef int sound_t; + +typedef struct { - if( !re ) return 0; - - return re->CreateDecalList( pList, changelevel ); -} - -// -// vsound.dll exports -// -#define S_Shutdown if( se ) se->Shutdown -#define S_StartStreaming if( se ) se->StartStreaming -#define S_StopStreaming if( se ) se->StopStreaming -#define S_StartSound if( se ) se->StartSound -#define S_AmbientSound if( se ) se->StaticSound -#define S_StartLocalSound if( se ) se->StartLocalSound -#define S_StartBackgroundTrack if( se ) se->StartBackgroundTrack -#define S_StopBackgroundTrack if( se ) se->StopBackgroundTrack -#define S_StreamSetPause if( se ) se->PauseBackgroundTrack -#define S_RawSamples if( se ) se->StreamRawSamples -#define S_StopAllSounds if( se ) se->StopAllSounds -#define S_StopSound if( se ) se->StopSound -#define S_AddLoopingSound if( se ) se->AddLoopingSound -#define S_Activate if( se ) se->Activate -#define S_ExtraUpdate if( se ) se->ExtraUpdate -#define S_RenderFrame if( se ) se->RenderFrame -#define S_BeginRegistration if( se ) se->BeginRegistration -#define S_EndRegistration if( se ) se->EndRegistration - -_inline void S_FadeClientVolume( float fadePercent, float fadeOutSeconds, float holdTime, float fadeInSeconds ) -{ - if( se ) se->FadeClientVolume( fadePercent, fadeOutSeconds, holdTime, fadeInSeconds ); -} - -_inline sound_t S_RegisterSound( const char *name ) -{ - if( !se ) return 0; - return se->RegisterSound( name ); -} - -_inline int S_GetCurrentStaticSounds( soundlist_t *pout, int size, int entchannel ) -{ - if( !se ) return 0; - return se->GetCurrentStaticSounds( pout, size, entchannel ); -} + string name; + int entnum; + int entchannel; + vec3_t origin; + float volume; + float attenuation; + qboolean looping; + int pitch; +} soundlist_t; #endif//COM_EXPORT_H \ No newline at end of file diff --git a/engine/common/common.h b/engine/common/common.h index b0ae1df5..2f1553d2 100644 --- a/engine/common/common.h +++ b/engine/common/common.h @@ -13,7 +13,6 @@ #include "launch_api.h" #include "engine_api.h" #include "render_api.h" -#include "vsound_api.h" #include "com_export.h" #include "com_model.h" @@ -133,9 +132,7 @@ typedef struct host_parm_s // renderers info char *video_dlls[MAX_RENDERS]; - char *audio_dlls[MAX_RENDERS]; int num_video_dlls; - int num_audio_dlls; decallist_t *decalList; // used for keep decals, when renderer is restarted or changed int numdecals; @@ -161,6 +158,7 @@ void Host_SetServerState( int state ); int Host_ServerState( void ); int Host_CompareFileTime( long ft1, long ft2 ); qboolean Host_NewGame( const char *mapName, qboolean loadGame ); +int Host_CreateDecalList( decallist_t *pList, qboolean changelevel ); void Host_EndGame( const char *message, ... ); void Host_AbortCurrentFrame( void ); void Host_WriteServerConfig( const char *name ); @@ -336,4 +334,12 @@ typedef struct autocomplete_list_s extern autocomplete_list_t cmd_list[]; +// soundlib shared exports +qboolean S_Init( void *hInst ); +void S_Shutdown( void ); +void S_Activate( qboolean active, void *hInst ); +void S_StopSound( int entnum, int channel, const char *soundname ); +int S_GetCurrentStaticSounds( soundlist_t *pout, int size, int entchannel ); +void S_StopAllSounds( void ); + #endif//COMMON_H \ No newline at end of file diff --git a/engine/common/host.c b/engine/common/host.c index 10c497f2..17dfed8a 100644 --- a/engine/common/host.c +++ b/engine/common/host.c @@ -9,12 +9,10 @@ #include "input.h" render_exp_t *re; -vsound_exp_t *se; host_parm_t host; // host parms stdlib_api_t com, newcom; dll_info_t render_dll = { "", NULL, "CreateAPI", NULL, NULL, 0, sizeof(render_exp_t), sizeof(stdlib_api_t) }; -dll_info_t vsound_dll = { "", NULL, "CreateAPI", NULL, NULL, 0, sizeof(vsound_exp_t), sizeof(stdlib_api_t) }; convar_t *host_serverstate; convar_t *host_gameloaded; @@ -23,7 +21,7 @@ convar_t *host_cheats; convar_t *host_maxfps; convar_t *host_framerate; convar_t *host_video; -convar_t *host_audio; +qboolean sound_restart; // these cvars will be duplicated on each client across network int Host_ServerState( void ) { return Cvar_VariableInteger( "host_serverstate" ); } @@ -104,6 +102,13 @@ static void Host_DrawDebugCollision( cmdraw_t drawPoly ) // FIXME: get collision polys here } +int Host_CreateDecalList( decallist_t *pList, qboolean changelevel ) +{ + if( !re ) return 0; + + return re->CreateDecalList( pList, changelevel ); +} + void Host_FreeRender( void ) { if( render_dll.link ) @@ -153,53 +158,6 @@ qboolean Host_InitRender( void ) return result; } -void Host_FreeSound( void ) -{ - if( vsound_dll.link ) - { - se->Shutdown(); - Mem_Set( &se, 0, sizeof( se )); - } - Sys_FreeLibrary( &vsound_dll ); -} - -qboolean Host_InitSound( void ) -{ - static vsound_imp_t si; - launch_t CreateSound; - qboolean result = false; - - if( FS_CheckParm( "-nosound" )) - return result; - - si.api_size = sizeof( vsound_imp_t ); - - // sound callbacks - si.GetEntitySpatialization = CL_GetEntitySpatialization; - si.AmbientLevels = CM_AmbientLevels; - si.GetClientEdict = CL_GetEntityByIndex; - si.GetServerTime = CL_GetServerTime; - si.GetAudioChunk = SCR_GetAudioChunk; - si.GetMovieInfo = SCR_GetMovieInfo; - si.IsInMenu = CL_IsInMenu; - si.IsActive = CL_IsInGame; - - Sys_LoadLibrary( host_audio->string, &vsound_dll ); - - if( vsound_dll.link ) - { - CreateSound = (void *)vsound_dll.main; - se = CreateSound( &newcom, &si ); - - if( se->Init( host.hWnd )) result = true; - } - - // audio system not started, shutdown sound subsystem - if( !result ) Host_FreeSound(); - - return result; -} - void Host_CheckChanges( void ) { int num_changes; @@ -209,13 +167,13 @@ void Host_CheckChanges( void ) { if( host.state == HOST_INIT ) audio_disabled = true; - host_audio->modified = false; + sound_restart = false; } - if( host_video->modified || host_audio->modified ) + if( host_video->modified || sound_restart ) { if( host_video->modified ) CL_ForceVid(); - if( host_audio->modified ) CL_ForceSnd(); + if( sound_restart ) CL_ForceSnd(); } else return; @@ -225,10 +183,10 @@ void Host_CheckChanges( void ) { // we're in game and want keep decals when renderer is changed host.decalList = (decallist_t *)Z_Malloc( sizeof( decallist_t ) * MAX_RENDER_DECALS ); - host.numdecals = CL_CreateDecalList( host.decalList, false ); + host.numdecals = Host_CreateDecalList( host.decalList, false ); } - if(( host_video->modified || host_audio->modified ) && CL_Active( )) + if(( host_video->modified || sound_restart ) && CL_Active( )) { host.soundList = (soundlist_t *)Z_Malloc( sizeof( soundlist_t ) * 128 ); host.numsounds = S_GetCurrentStaticSounds( host.soundList, 128, CHAN_STATIC ); @@ -262,24 +220,12 @@ void Host_CheckChanges( void ) num_changes = 0; - // restart or change sound engine - while( host_audio->modified ) + // restart sound engine + if( sound_restart ) { - host_audio->modified = false; // predict state - - Host_FreeSound(); // release sound.dll - if( !Host_InitSound( )) // load it again - { - if( num_changes > host.num_audio_dlls ) - { - MsgDev( D_ERROR, "couldn't initialize sound system\n" ); - return; - } - if( !com.strcmp( host.audio_dlls[num_changes], host_audio->string )) - num_changes++; // already trying - failed - Cvar_FullSet( "host_audio", host.audio_dlls[num_changes], CVAR_INIT|CVAR_ARCHIVE ); - num_changes++; - } + S_Shutdown(); + S_Init( host.hWnd ); + sound_restart = false; } } @@ -326,7 +272,7 @@ Restart the audio subsystem */ void Host_SndRestart_f( void ) { - host_audio->modified = true; + sound_restart = true; } /* @@ -744,7 +690,7 @@ static void Host_Crash_f( void ) void Host_InitCommon( const int argc, const char **argv ) { - dll_info_t check_vid, check_snd; + dll_info_t check_vid; search_t *dlls; int i; @@ -767,16 +713,14 @@ void Host_InitCommon( const int argc, const char **argv ) IN_Init(); - // initialize audio\video multi-dlls system - host.num_video_dlls = host.num_audio_dlls = 0; + // initialize video multi-dlls system + host.num_video_dlls = 0; // make sure what global copy has no changed with any dll checking Mem_Copy( &check_vid, &render_dll, sizeof( dll_info_t )); - Mem_Copy( &check_snd, &vsound_dll, sizeof( dll_info_t )); // checking dlls don't invoke crash! check_vid.crash = false; - check_snd.crash = false; dlls = FS_Search( "*.dll", true ); @@ -797,17 +741,6 @@ void Host_InitCommon( const int argc, const char **argv ) host.num_video_dlls++; } } - else if( !com.strnicmp( "snd_", dlls->filenames[i], 4 )) - { - // make sure what found library is valid - if( Sys_LoadLibrary( dlls->filenames[i], &check_snd )) - { - MsgDev( D_NOTE, "Audio[%i]: %s\n", host.num_audio_dlls, dlls->filenames[i] ); - host.audio_dlls[host.num_audio_dlls] = copystring( dlls->filenames[i] ); - Sys_FreeLibrary( &check_snd ); - host.num_audio_dlls++; - } - } } Mem_Free( dlls ); } @@ -852,7 +785,6 @@ void Host_Init( const int argc, const char **argv ) } host_video = Cvar_Get( "host_video", "vid_gl.dll", CVAR_INIT|CVAR_ARCHIVE, "name of video rendering library"); - host_audio = Cvar_Get( "host_audio", "snd_dx.dll", CVAR_INIT|CVAR_ARCHIVE, "name of sound rendering library"); host_cheats = Cvar_Get( "sv_cheats", "0", CVAR_LATCH, "allow cheat variables to enable" ); host_maxfps = Cvar_Get( "fps_max", "72", CVAR_ARCHIVE, "host fps upper limit" ); host_framerate = Cvar_Get( "host_framerate", "0", 0, "locks frame timing to this value in seconds" ); @@ -866,6 +798,8 @@ void Host_Init( const int argc, const char **argv ) Cvar_Get( "violence_hblood", "1", CVAR_INIT|CVAR_ARCHIVE, "content control disables human blood" ); Cvar_Get( "violence_ablood", "1", CVAR_INIT|CVAR_ARCHIVE, "content control disables alien blood" ); + sound_restart = true; // initialize sound engine + if( host.type != HOST_DEDICATED ) { // when we in developer-mode automatically turn cheats on @@ -942,7 +876,7 @@ void Host_Free( void ) CM_FreePhysics(); Host_FreeRender(); - Host_FreeSound(); + S_Shutdown(); SV_Shutdown( false ); CL_Shutdown(); diff --git a/engine/common/pm_studio.c b/engine/common/pm_studio.c index 35c19429..79b15f6f 100644 --- a/engine/common/pm_studio.c +++ b/engine/common/pm_studio.c @@ -7,6 +7,7 @@ #include "studio.h" #include "mathlib.h" #include "matrix_lib.h" +#include "cm_local.h" #include "pm_local.h" #include "world.h" diff --git a/engine/common/pm_trace.c b/engine/common/pm_trace.c index d98bb351..d63db2c7 100644 --- a/engine/common/pm_trace.c +++ b/engine/common/pm_trace.c @@ -6,6 +6,7 @@ #include "common.h" #include "mathlib.h" #include "matrix_lib.h" +#include "cm_local.h" #include "pm_local.h" static mplane_t pm_boxplanes[6]; diff --git a/engine/common/protocol.h b/engine/common/protocol.h index 4bf79535..675e99c5 100644 --- a/engine/common/protocol.h +++ b/engine/common/protocol.h @@ -86,6 +86,16 @@ #define MAX_USER_MESSAGES 191 // another 63 messages reserved for engine routines // FIXME: tune this +// sound flags +#define SND_VOLUME (1<<0) // a scaled byte +#define SND_ATTENUATION (1<<1) // a byte +#define SND_PITCH (1<<2) // a byte +#define SND_FIXED_ORIGIN (1<<3) // a vector +#define SND_SENTENCE (1<<4) // set if sound num is actually a sentence num +#define SND_STOP (1<<5) // stop the sound +#define SND_CHANGE_VOL (1<<6) // change sound vol +#define SND_CHANGE_PITCH (1<<7) // change sound pitch +#define SND_SPAWNING (1<<8) // we're spawning, used in some cases for ambients // Max number of history commands to send ( 2 by default ) in case of dropped packets #define NUM_BACKUP_COMMAND_BITS 3 diff --git a/engine/engine.dsp b/engine/engine.dsp index 34c4c3ef..1274e269 100644 --- a/engine/engine.dsp +++ b/engine/engine.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 1 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c -# ADD CPP /nologo /MD /W3 /GX /O2 /I "./" /I "common" /I "server" /I "client" /I "uimenu" /I "../public" /I "../common" /I "../game_shared" /I "../pm_shared" /I "../utils/vgui/include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c +# ADD CPP /nologo /MD /W3 /GX /O2 /I "./" /I "common" /I "server" /I "client" /I "client/sound" /I "../public" /I "../common" /I "../game_shared" /I "../pm_shared" /I "../utils/vgui/include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c # SUBTRACT CPP /YX # ADD BASE MTL /nologo /D "NDEBUG" /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 @@ -54,7 +54,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 /opt:nowin98 -# ADD LINK32 user32.lib msvcrt.lib vfw32.lib msacm32.lib gdi32.lib ../utils/vgui/lib/win32_vc6/vgui.lib /nologo /subsystem:windows /dll /pdb:none /machine:I386 /nodefaultlib:"libc.lib" /opt:nowin98 +# ADD LINK32 user32.lib msvcrt.lib vfw32.lib msacm32.lib gdi32.lib winmm.lib ../utils/vgui/lib/win32_vc6/vgui.lib /nologo /subsystem:windows /dll /pdb:none /machine:I386 /nodefaultlib:"libc.lib" /opt:nowin98 # SUBTRACT LINK32 /debug /nodefaultlib # Begin Custom Build TargetDir=\Xash3D\src_main\temp\engine\!release @@ -80,7 +80,7 @@ SOURCE="$(InputPath)" # PROP Ignore_Export_Lib 1 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c -# ADD CPP /nologo /MDd /W3 /Gm /Gi /GX /ZI /Od /I "./" /I "common" /I "server" /I "client" /I "uimenu" /I "../public" /I "../common" /I "../game_shared" /I "../pm_shared" /I "../utils/vgui/include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /FD /c +# ADD CPP /nologo /MDd /W3 /Gm /Gi /GX /ZI /Od /I "./" /I "common" /I "server" /I "client" /I "client/sound" /I "../public" /I "../common" /I "../game_shared" /I "../pm_shared" /I "../utils/vgui/include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /FD /c # SUBTRACT CPP /YX # ADD BASE MTL /nologo /D "_DEBUG" /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 @@ -91,7 +91,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 -# ADD LINK32 user32.lib msvcrtd.lib vfw32.lib msacm32.lib gdi32.lib ../utils/vgui/lib/win32_vc6/vgui.lib /nologo /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"msvcrt.lib" /pdbtype:sept +# ADD LINK32 user32.lib msvcrtd.lib vfw32.lib msacm32.lib gdi32.lib winmm.lib ../utils/vgui/lib/win32_vc6/vgui.lib /nologo /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"msvcrt.lib" /pdbtype:sept # SUBTRACT LINK32 /incremental:no /map /nodefaultlib # Begin Custom Build TargetDir=\Xash3D\src_main\temp\engine\!debug @@ -254,6 +254,42 @@ SOURCE=.\common\pm_trace.c # End Source File # Begin Source File +SOURCE=.\client\sound\s_backend.c +# End Source File +# Begin Source File + +SOURCE=.\client\sound\s_dsp.c +# End Source File +# Begin Source File + +SOURCE=.\client\sound\s_load.c +# End Source File +# Begin Source File + +SOURCE=.\client\sound\s_main.c +# End Source File +# Begin Source File + +SOURCE=.\client\sound\s_mix.c +# End Source File +# Begin Source File + +SOURCE=.\client\sound\s_mouth.c +# End Source File +# Begin Source File + +SOURCE=.\client\sound\s_stream.c +# End Source File +# Begin Source File + +SOURCE=.\client\sound\s_utils.c +# End Source File +# Begin Source File + +SOURCE=.\client\sound\s_vox.c +# End Source File +# Begin Source File + SOURCE=.\server\sv_client.c # End Source File # Begin Source File @@ -358,6 +394,14 @@ SOURCE=.\server\server.h # End Source File # Begin Source File +SOURCE=.\client\sound\sound.h +# End Source File +# Begin Source File + +SOURCE=.\client\sound\vox.h +# End Source File +# Begin Source File + SOURCE=.\common\world.h # End Source File # End Group diff --git a/engine/server/sv_save.c b/engine/server/sv_save.c index e96eec1b..60ddd7b6 100644 --- a/engine/server/sv_save.c +++ b/engine/server/sv_save.c @@ -921,7 +921,7 @@ void SV_SaveClientState( SAVERESTOREDATA *pSaveData, const char *level ) FS_Write( pFile, &version, sizeof( int )); decalList = (decallist_t *)Z_Malloc(sizeof( decallist_t ) * MAX_RENDER_DECALS ); - decalCount = CL_CreateDecalList( decalList, svgame.globals->changelevel ); + decalCount = Host_CreateDecalList( decalList, svgame.globals->changelevel ); FS_Write( pFile, &decalCount, sizeof( int )); diff --git a/launch/export.c b/launch/export.c deleted file mode 100644 index b582c644..00000000 --- a/launch/export.c +++ /dev/null @@ -1,29 +0,0 @@ -//======================================================================= -// Copyright XashXT Group 2007 © -// export.c - main engine launcher -//======================================================================= - -#include "launch.h" - -// main DLL entry point -BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) -{ - return TRUE; -} - -/* -================= -Main Entry Point -================= -*/ -EXPORT int CreateAPI( const char *hostname, qboolean console ) -{ - com_strncpy( Sys.progname, hostname, sizeof( Sys.progname )); - Sys.hooked_out = console; - - Sys_Init(); - Sys.Main(); - Sys_Exit(); - - return 0; -} \ No newline at end of file diff --git a/launch/filesystem.c b/launch/filesystem.c index 607d21a9..c4637975 100644 --- a/launch/filesystem.c +++ b/launch/filesystem.c @@ -2420,6 +2420,29 @@ const char *FS_GetDiskPath( const char *name, qboolean gamedironly ) return NULL; } +/* +================== +FS_CheckForCrypt + +return true is library is crypted +================== +*/ +qboolean FS_CheckForCrypt( const char *dllname ) +{ + file_t *f; + int key; + + f = FS_Open( dllname, "rb", false ); + if( !f ) return false; + + FS_Seek( f, 64, SEEK_SET ); // skip first 64 bytes + FS_Read( f, &key, sizeof( key )); + FS_Close( f ); + + return ( key == 0x12345678 ) ? true : false; +} + + /* ================== FS_FindLibrary @@ -2476,7 +2499,9 @@ dll_user_t *FS_FindLibrary( const char *dllname, qboolean directpath ) // shortPath is used for LibraryLoadSymbols only com.strncpy( hInst->shortPath, dllpath, sizeof( hInst->shortPath )); - if( index < 0 ) + hInst->encrypted = FS_CheckForCrypt( dllpath ); + + if( index < 0 && !hInst->encrypted ) { com.snprintf( hInst->fullPath, sizeof( hInst->fullPath ), "%s%s", search->filename, dllpath ); hInst->custom_loader = false; // we can loading from disk and use normal debugging @@ -3041,7 +3066,7 @@ fs_offset_t VFS_Write( vfile_t *file, const void *buf, size_t size ) if( file->buffsize < newsize ) { // reallocate buffer now - file->buff = Mem_Realloc( fs_mempool, file->buff, newsize ); + file->buff = Mem_Realloc( fs_mempool, file->buff, newsize ); file->buffsize = newsize; // merge buffsize } } @@ -3193,8 +3218,26 @@ int VFS_Seek( vfile_t *file, fs_offset_t offset, int whence ) return -1; } - if( offset < 0 || offset > (long)file->length ) - return -1; + if( offset < 0 ) return -1; + + if( offset > (long)file->length ) + { + if( file->mode == O_WRONLY ) + { + int newsize = offset + (64 * 1024); + + if( file->buffsize < newsize ) + { + // reallocate buffer now + file->buff = Mem_Realloc( fs_mempool, file->buff, newsize ); + file->buffsize = newsize; // merge buffsize + } + } + else + { + return -1; + } + } file->offset = offset; return 0; @@ -3492,7 +3535,8 @@ static qboolean W_ReadLumpTable( wfile_t *wad ) int i, k, numlumps; // nothing to convert ? - if( !wad ) return false; + if( !wad || !wad->numlumps ) + return false; lat_size = wad->numlumps * sizeof( dlumpinfo_t ); srclumps = (dlumpinfo_t *)Mem_Alloc( wad->mempool, lat_size ); diff --git a/launch/imagelib/img_utils.c b/launch/imagelib/img_utils.c index 93da4c38..b927b662 100644 --- a/launch/imagelib/img_utils.c +++ b/launch/imagelib/img_utils.c @@ -657,11 +657,12 @@ void Image_ConvertPalTo24bit( rgbdata_t *pic ) byte *converted; int i; - if( !pic || !pic->palette ) + if( !pic->palette ) { - MsgDev(D_ERROR,"Image_ConvertPalTo24bit: no palette found\n"); + MsgDev( D_ERROR, "Image_ConvertPalTo24bit: no palette found\n" ); return; } + if( pic->type == PF_INDEXED_24 ) { MsgDev( D_ERROR, "Image_ConvertPalTo24bit: palette already converted\n" ); diff --git a/launch/imagelib/img_wad.c b/launch/imagelib/img_wad.c index 01b52f7e..b130fc19 100644 --- a/launch/imagelib/img_wad.c +++ b/launch/imagelib/img_wad.c @@ -517,7 +517,9 @@ qboolean Image_LoadMIP( const char *name, const byte *buffer, size_t filesize ) { // apply decal palette immediately image.flags |= IMAGE_COLORINDEX; - rendermode = LUMP_DECAL; + if( Sys.app_name == HOST_NORMAL ) + rendermode = LUMP_DECAL; + else rendermode = LUMP_TRANSPARENT; } image.flags |= IMAGE_HAS_ALPHA; } diff --git a/launch/launch.dsp b/launch/launch.dsp index 30400e1a..7616c6a0 100644 --- a/launch/launch.dsp +++ b/launch/launch.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 1 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LAUNCH_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /O2 /I "./" /I "imagelib" /I "../public" /I "../common" /I "../engine" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c +# ADD CPP /nologo /MD /W3 /GX /O2 /I "./" /I "imagelib" /I "./tools" /I "../public" /I "../common" /I "../engine" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c # SUBTRACT CPP /YX # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 @@ -79,7 +79,7 @@ SOURCE="$(InputPath)" # PROP Ignore_Export_Lib 1 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LAUNCH_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /Gm /Gi /GX /ZI /Od /I "./" /I "imagelib" /I "../public" /I "../common" /I "../engine" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /Gm /Gi /GX /ZI /Od /I "./" /I "imagelib" /I "./tools" /I "../public" /I "../common" /I "../engine" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 @@ -112,6 +112,10 @@ SOURCE="$(InputPath)" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File +SOURCE=.\tools\bsplib.c +# End Source File +# Begin Source File + SOURCE=.\cmd.c # End Source File # Begin Source File @@ -120,6 +124,22 @@ SOURCE=.\console.c # End Source File # Begin Source File +SOURCE=.\tools\conv_bsp.c +# End Source File +# Begin Source File + +SOURCE=.\tools\conv_image.c +# End Source File +# Begin Source File + +SOURCE=.\tools\conv_main.c +# End Source File +# Begin Source File + +SOURCE=.\tools\conv_sprite.c +# End Source File +# Begin Source File + SOURCE=.\cpuinfo.c # End Source File # Begin Source File @@ -132,10 +152,6 @@ SOURCE=.\cvar.c # End Source File # Begin Source File -SOURCE=.\export.c -# End Source File -# Begin Source File - SOURCE=.\filesystem.c # End Source File # Begin Source File @@ -220,22 +236,50 @@ SOURCE=.\soundlib\snd_wav.c # End Source File # Begin Source File +SOURCE=.\tools\spritegen.c +# End Source File +# Begin Source File + SOURCE=.\stdlib.c # End Source File # Begin Source File +SOURCE=.\tools\studio.c +# End Source File +# Begin Source File + +SOURCE=.\tools\studio_utils.c +# End Source File +# Begin Source File + SOURCE=.\system.c # End Source File # Begin Source File +SOURCE=.\tools\tools.c +# End Source File +# Begin Source File + SOURCE=.\utils.c # End Source File +# Begin Source File + +SOURCE=.\tools\wadlib.c +# End Source File +# Begin Source File + +SOURCE=.\tools\ximage.c +# End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File +SOURCE=.\tools\badimage.h +# End Source File +# Begin Source File + SOURCE=.\filesystem.h # End Source File # Begin Source File @@ -248,8 +292,20 @@ SOURCE=.\library.h # End Source File # Begin Source File +SOURCE=.\tools\mdllib.h +# End Source File +# Begin Source File + +SOURCE=.\tools\ripper.h +# End Source File +# Begin Source File + SOURCE=.\soundlib\soundlib.h # End Source File +# Begin Source File + +SOURCE=.\tools\utils.h +# End Source File # End Group # Begin Group "Resource Files" diff --git a/launch/launch.h b/launch/launch.h index f5831d24..e0e4654c 100644 --- a/launch/launch.h +++ b/launch/launch.h @@ -534,4 +534,12 @@ void Sound_Init( void ); void Sound_Setup( const char *formats, const uint flags ); void Sound_Shutdown( void ); +// +// tools.c +// +void Init_Tools( const int argc, const char **argv ); +void Tools_Main( void ); +void Free_Tools( void ); +void Bsp_PrintLog( const char *pMsg ); + #endif//LAUNCHER_H \ No newline at end of file diff --git a/launch/library.c b/launch/library.c index 194ab7af..8ed95faa 100644 --- a/launch/library.c +++ b/launch/library.c @@ -6,6 +6,24 @@ #include "launch.h" #include "library.h" +static const byte dosdata[0x100] = // dos header (string 'This program cannot be run in DOS mode', etc) +"\x0e\x1f\xba\x0e\x00\xb4\x09\xcd\x21\xb8\x01\x4c\xcd\x21\x54\x68" +"\x69\x73\x20\x70\x72\x6f\x67\x72\x61\x6d\x20\x63\x61\x6e\x6e\x6f" +"\x74\x20\x62\x65\x20\x72\x75\x6e\x20\x69\x6e\x20\x44\x4f\x53\x20" +"\x6d\x6f\x64\x65\x2e\x0d\x0d\x0a\x24\x00\x00\x00\x00\x00\x00\x00" +"\xdb\xd6\xcc\x61\x9f\xb7\xa2\x32\x9f\xb7\xa2\x32\x9f\xb7\xa2\x32" +"\xe4\xab\xae\x32\x97\xb7\xa2\x32\xf0\xa8\xa9\x32\x90\xb7\xa2\x32" +"\x1c\xab\xac\x32\xae\xb7\xa2\x32\xf0\xa8\xa8\x32\x31\xb7\xa2\x32" +"\xc0\x95\xa8\x32\x9e\xb7\xa2\x32\x65\x93\xbb\x32\x9d\xb7\xa2\x32" +"\xc0\x95\xa9\x32\xb1\xb7\xa2\x32\x18\xab\xa0\x32\xb9\xb7\xa2\x32" +"\x70\x95\x92\x32\x9e\xb7\xa2\x32\x9f\xb7\xa3\x32\x6c\xb7\xa2\x32" +"\xfd\xa8\xb1\x32\x8e\xb7\xa2\x32\xe1\x95\xbe\x32\x9c\xb7\xa2\x32" +"\xac\x95\x87\x32\x9b\xb7\xa2\x32\xcb\x94\x93\x32\xab\xb7\xa2\x32" +"\xcb\x94\x92\x32\xf2\xb7\xa2\x32\x58\xb1\xa4\x32\x9e\xb7\xa2\x32" +"\x9f\xb7\xa2\x32\x80\xb7\xa2\x32\x60\x97\xa6\x32\x8c\xb7\xa2\x32" +"\x52\x69\x63\x68\x9f\xb7\xa2\x32\x00\x00\x00\x00\x00\x00\x00\x00" +"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; + /* --------------------------------------------------------------- @@ -36,6 +54,15 @@ static int ProtectionFlags[2][2][2] = }, }; +static FIXED_SECTIONS FixedSections[] = +{ +{ ".text", IMAGE_SCN_CNT_CODE|IMAGE_SCN_MEM_EXECUTE|IMAGE_SCN_MEM_READ }, +{ ".rdata", IMAGE_SCN_CNT_INITIALIZED_DATA|IMAGE_SCN_MEM_READ }, +{ ".data", IMAGE_SCN_CNT_INITIALIZED_DATA|IMAGE_SCN_MEM_READ|IMAGE_SCN_MEM_WRITE }, +{ ".rsrc", IMAGE_SCN_CNT_INITIALIZED_DATA|IMAGE_SCN_MEM_DISCARDABLE|IMAGE_SCN_MEM_READ }, +{ NULL, 0 } +}; + typedef BOOL (WINAPI *DllEntryProc)( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved ); #define GET_HEADER_DICTIONARY( module, idx ) &(module)->headers->OptionalHeader.DataDirectory[idx] @@ -277,6 +304,7 @@ static int BuildImportTable( MEMORYMODULE *module ) thunkRef = (DWORD *)CALCULATE_ADDRESS( codeBase, importDesc->FirstThunk ); funcRef = (DWORD *)CALCULATE_ADDRESS( codeBase, importDesc->FirstThunk ); } + for( ; *thunkRef; thunkRef++, funcRef++ ) { if( IMAGE_SNAP_BY_ORDINAL( *thunkRef )) @@ -343,7 +371,253 @@ static void MemoryFreeLibrary( void *hInstance ) } } -void *MemoryLoadLibrary( const char *name ) +static void ImageFindTables( byte *base, DWORD baseoff, DWORD imagebase, DWORD *impoff, DWORD *impsz, DWORD *expoff, DWORD *expsz, DWORD *iatoff, DWORD *iatsz ) +{ + IMAGE_IMPORT_DESCRIPTOR *iid; + IMAGE_THUNK_DATA *itd; + IMAGE_EXPORT_DIRECTORY *ied; + DWORD off, maxiat, maxoff; + byte *p; + int i; + + *iatoff = 0xffffffff; + maxiat = maxoff = 0; + + for( iid = (IMAGE_IMPORT_DESCRIPTOR *)(base + ( *impoff - baseoff )); iid->Name; iid++ ) + { + if( iid->Name > maxoff ) + maxoff = iid->Name; + + if( iid->FirstThunk < *iatoff ) + *iatoff = iid->FirstThunk; + + for( itd = (IMAGE_THUNK_DATA *)(base + iid->FirstThunk - ( baseoff - imagebase )); itd->u1.AddressOfData; itd++ ) + { + off = (((byte *)( itd + 1 ) - base ) + ( baseoff - imagebase )) + 4; + if( off > maxiat ) maxiat = off; + + if( !IMAGE_SNAP_BY_ORDINAL( itd->u1.Ordinal )) + { + off = itd->u1.Ordinal + 2; + if( off > maxoff ) maxoff = off; + } + } + } + + iid++; + *impsz = (byte *)iid - ( base + ( *impoff - baseoff )); + + *iatsz = maxiat - *iatoff; + *iatoff += imagebase; + + for( p = base + maxoff - (baseoff - imagebase); *p; p++ ); + + for( p++; !*p; p++ ); // we get the timestamp value of the export directory + p -= ( p - base ) & 3; // simple check of the alignment, enough + p -= 4; // skip the characteristics for finding the export table + *expoff = (p - base) + baseoff; + + ied = (IMAGE_EXPORT_DIRECTORY *)p; + + for( itd = (IMAGE_THUNK_DATA *)( base + ied->AddressOfNames - ( baseoff - imagebase )), i = 0; i < ied->NumberOfNames; itd++, i++ ) + { + if( !IMAGE_SNAP_BY_ORDINAL( itd->u1.Ordinal )) + { + off = itd->u1.Ordinal; + if( off > maxoff ) maxoff = off; + } + } + + for( p = base + maxoff - ( baseoff - imagebase ); *p; p++ ); + for( p++; ( p - base ) & 3; p++ ); + *expsz = (( p - base ) + baseoff ) - *expoff; + + // print some stats + MsgDev( D_NOTE, "DecryptImage: import table: %08x of %s\n", *impoff - baseoff, com_pretifymem( *impsz, 2 )); + MsgDev( D_NOTE, "DecryptImage: export table: %08x of %s\n", *expoff - baseoff, com_pretifymem( *expsz, 2 )); +} + +static void *DecryptImage( byte *data, size_t size ) +{ + SECTION_HEADER section; + OPTIONAL_HEADER optional; + VALVE_HEADER *hlhdr; + VAVLE_SECTIONS *hlsec; + DOS_HEADER doshdr; + PE_HEADER pehdr; + DWORD i, tmp, len; + byte buff[IMAGE_ALIGN]; + DWORD section_offset, import_rva, import_size; + DWORD export_rva, export_size, iat_rva, iat_size; + byte symbol, *newimage; + vfile_t *f; + + data += 68; // skip all zeroes + size -= 68; + + symbol = 'W'; + + // run XOR decryption + for( i = 0; i < size; i++ ) + { + data[i] ^= symbol; + symbol += data[i] + 'W'; + } + + hlhdr = (void *)data; + hlsec = (void *)(data + sizeof( VALVE_HEADER )); + data -= 68; // restore all zeroes + size += 68; + + // FIXME: convert Ident to properly Magic + hlhdr->copywhat ^= 0x7a32bc85; + hlhdr->ImageBase ^= 0x49c042d1; + hlhdr->ImportTable ^= 0x872c3d47; + hlhdr->EntryPoint -= 12; + hlhdr->Sections++; + + // when all the section have been placed in memory + // hl.exe calls hlhdr->EntryPoint and then hlhdr->copywhat + // copying a zone of the dll in the hl.exe process + + Mem_Set( &optional, 0, sizeof( optional )); + optional.Magic = IMAGE_NT_OPTIONAL_HDR32_MAGIC; + optional.MajorLinkerVersion = 6; + optional.MinorLinkerVersion = 0; + optional.AddressOfEntryPoint = hlhdr->EntryPoint - hlhdr->ImageBase; + optional.BaseOfCode = hlsec[0].rva - hlhdr->ImageBase; // .text + optional.BaseOfData = hlsec[1].rva - hlhdr->ImageBase; // .rdata + optional.ImageBase = hlhdr->ImageBase; + optional.SectionAlignment = IMAGE_ALIGN; + optional.FileAlignment = IMAGE_ALIGN; + optional.MajorOperatingSystemVersion = 4; + optional.MinorOperatingSystemVersion = 0; + optional.MajorImageVersion = 0; + optional.MinorImageVersion = 0; + optional.MajorSubsystemVersion = 4; + optional.MinorSubsystemVersion = 0; + optional.Win32VersionValue = 0; + optional.SizeOfHeaders = IMAGE_ALIGN; // it's ever less than the default alignment + optional.CheckSum = 0; + optional.Subsystem = IMAGE_SUBSYSTEM_WINDOWS_GUI; + optional.DllCharacteristics = 0; + optional.SizeOfStackReserve = IMAGE_ALIGN * 256; + optional.SizeOfStackCommit = IMAGE_ALIGN; + optional.SizeOfHeapReserve = IMAGE_ALIGN * 256; + optional.SizeOfHeapCommit = IMAGE_ALIGN; + optional.LoaderFlags = 0; + optional.NumberOfRvaAndSizes = IMAGE_NUMBEROF_DIRECTORY_ENTRIES; + + for( i = 0; i < hlhdr->Sections; i++ ) + { + tmp = ( i < 4 ) ? FixedSections[i].Characteristics : SECTION_DEF_CHARACTERISTIC; + optional.SizeOfImage += ALIGN( hlsec[i].rva_size ); + if( tmp & IMAGE_SCN_CNT_CODE ) optional.SizeOfCode += ALIGN( hlsec[i].rva_size ); + if( tmp & IMAGE_SCN_CNT_INITIALIZED_DATA ) optional.SizeOfInitializedData += ALIGN( hlsec[i].rva_size ); + if( tmp & IMAGE_SCN_CNT_UNINITIALIZED_DATA ) optional.SizeOfUninitializedData += ALIGN( hlsec[i].rva_size ); + } + + optional.SizeOfImage += optional.SizeOfHeaders; + import_rva = hlhdr->ImportTable; + + ImageFindTables( data + hlsec[1].file_offset, hlsec[1].rva, hlhdr->ImageBase, &import_rva, &import_size, &export_rva, &export_size, &iat_rva, &iat_size ); + + optional.DataDirectory[0].VirtualAddress = export_rva - hlhdr->ImageBase; + optional.DataDirectory[0].Size = export_size; + optional.DataDirectory[1].VirtualAddress = import_rva - hlhdr->ImageBase; + optional.DataDirectory[1].Size = import_size; + + if( hlhdr->Sections > 3 ) + { + optional.DataDirectory[2].VirtualAddress = hlsec[3].rva - hlhdr->ImageBase; + optional.DataDirectory[2].Size = hlsec[3].rva_size; + } + + optional.DataDirectory[12].VirtualAddress = iat_rva - hlhdr->ImageBase; + optional.DataDirectory[12].Size = iat_size; + + f = VFS_Open( NULL, "wb" ); + + Mem_Set( &doshdr, 0, sizeof( doshdr )); + doshdr.e_magic = IMAGE_DOS_SIGNATURE; + doshdr.e_cblp = 0x0090; + doshdr.e_cp = 0x0003; + doshdr.e_cparhdr = 0x0004; + doshdr.e_maxalloc = 0xffff; + doshdr.e_sp = 0x00b8; + doshdr.e_lfarlc = 0x0040; + doshdr.e_lfanew = sizeof( doshdr ) + sizeof( dosdata ); + + VFS_Write( f, &doshdr, sizeof( doshdr )); // write DOS header + VFS_Write( f, &dosdata, sizeof( dosdata )); // write default dos executable stub + + tmp = NT_SIGNATURE; + Mem_Set( &pehdr, 0, sizeof( pehdr )); + pehdr.Machine = IMAGE_FILE_MACHINE_I386; + pehdr.NumberOfSections = hlhdr->Sections; + pehdr.TimeDateStamp = time( NULL ); + pehdr.SizeOfOptionalHeader = sizeof( OPTIONAL_HEADER ); + pehdr.Characteristics = (IMAGE_FILE_LOCAL_SYMS_STRIPPED|IMAGE_FILE_EXECUTABLE_IMAGE|IMAGE_FILE_LINE_NUMS_STRIPPED|IMAGE_FILE_32BIT_MACHINE|IMAGE_FILE_DLL); + VFS_Write( f, &tmp, sizeof( int )); // write NT signature + VFS_Write( f, &pehdr, sizeof( pehdr )); // write PE header + + // write optional header + VFS_Write( f, &optional, sizeof( optional )); + + section_offset = optional.SizeOfHeaders; + + // write section headers + for( i = 0; i < hlhdr->Sections; i++ ) + { + Mem_Set( §ion, 0, sizeof( section )); + + if( i < 4 ) com.strncpy( section.Name, FixedSections[i].Name, IMAGE_SIZEOF_SHORT_NAME ); + else com.snprintf( section.Name, IMAGE_SIZEOF_SHORT_NAME, "sec%u", i ); + + section.Misc.VirtualSize = hlsec[i].rva_size; + section.VirtualAddress = hlsec[i].rva - hlhdr->ImageBase; + section.SizeOfRawData = ALIGN( hlsec[i].file_size ); + section.PointerToRawData = section_offset; + section.PointerToRelocations = hlsec[i].reloc_addr; + section.Characteristics = ( i < 4 ) ? FixedSections[i].Characteristics : SECTION_DEF_CHARACTERISTIC; + VFS_Write( f, §ion, sizeof( section )); + section_offset += ALIGN( hlsec[i].file_size ); + } + + // write sections + VFS_Seek( f, optional.SizeOfHeaders, SEEK_SET ); + + for( i = 0; i < hlhdr->Sections; i++ ) + { + if(( hlsec[i].file_offset + hlsec[i].file_size ) > size ) + { + MsgDev( D_WARN, "DecryptImage: section %d is larger than source (%u %d)\n", i, (hlsec[i].file_offset + hlsec[i].file_size), size ); + VFS_Write( f, data + hlsec[i].file_offset, size - hlsec[i].file_offset ); + VFS_Seek( f, (hlsec[i].file_offset + hlsec[i].file_size) - size, SEEK_CUR ); + } + else VFS_Write( f, data + hlsec[i].file_offset, hlsec[i].file_size ); + + // write sections alignment + tmp = ALIGN( hlsec[i].file_size ) - hlsec[i].file_size; + for( len = sizeof( buff ); tmp > 0; tmp -= len ) + { + if( len > tmp ) len = tmp; + VFS_Write( f, buff, len ); + } + } + + VFS_Seek( f, 0, SEEK_END ); + size = VFS_Tell( f ); + + // realloc image size if needs + newimage = Mem_Realloc( Sys.basepool, data, size ); + Mem_Copy( newimage, VFS_GetBuffer( f ), size ); + VFS_Close( f ); + + return newimage; +} + +void *MemoryLoadLibrary( const char *name, qboolean encrypted ) { MEMORYMODULE *result; PIMAGE_DOS_HEADER dos_header; @@ -354,14 +628,18 @@ void *MemoryLoadLibrary( const char *name ) string errorstring; qboolean successfull; void *data = NULL; + size_t size; - data = FS_LoadFile( name, NULL ); + data = FS_LoadFile( name, &size ); if( !data ) { com.sprintf( errorstring, "couldn't load %s", name ); goto library_error; } + // if this image encrypted we need decrypting it first + if( encrypted ) data = DecryptImage( data, size ); + dos_header = (PIMAGE_DOS_HEADER)data; if( dos_header->e_magic != IMAGE_DOS_SIGNATURE ) { @@ -755,12 +1033,12 @@ void *Com_LoadLibraryExt( const char *dllname, int build_ordinals_table, qboolea if( !hInst ) return NULL; // nothing to load if( hInst->custom_loader ) - hInst->hInstance = MemoryLoadLibrary( hInst->fullPath ); + hInst->hInstance = MemoryLoadLibrary( hInst->fullPath, hInst->encrypted ); else hInst->hInstance = LoadLibrary( hInst->fullPath ); if( !hInst->hInstance ) { - MsgDev( D_NOTE, "Sys_LoadLibrary: Loading %s - failed. Error %i\n", dllname ); + MsgDev( D_NOTE, "Sys_LoadLibrary: Loading %s - failed\n", dllname ); Com_FreeLibrary( hInst ); return NULL; } diff --git a/launch/library.h b/launch/library.h index f5525cf3..9d78640e 100644 --- a/launch/library.h +++ b/launch/library.h @@ -7,8 +7,13 @@ #define DOS_SIGNATURE 0x5A4D // MZ #define NT_SIGNATURE 0x00004550 // PE00 +#define NT_OPTIONAL_HDR32_MAGIC 0x10b +#define FILE_MACHINE_I386 0x014c #define NUMBER_OF_DIRECTORY_ENTRIES 16 #define MAX_LIBRARY_EXPORTS 4096 +#define IMAGE_ALIGN 4096 +#define ALIGN( x ) (( x + ( IMAGE_ALIGN - 1 )) & (~( IMAGE_ALIGN - 1 ))) +#define SECTION_DEF_CHARACTERISTIC (IMAGE_SCN_MEM_READ|IMAGE_SCN_CNT_INITIALIZED_DATA|IMAGE_SCN_MEM_WRITE) typedef struct { @@ -123,10 +128,36 @@ typedef struct dword AddressOfNameOrdinals; // RVA from base of image } EXPORT_DIRECTORY; +typedef struct +{ + char *Name; + DWORD Characteristics; +} FIXED_SECTIONS; + +typedef struct +{ + dword Ident; + dword Sections; + dword copywhat; + dword ImageBase; + dword EntryPoint; + dword ImportTable; +} VALVE_HEADER; + +typedef struct +{ + dword rva; + dword rva_size; + dword file_size; + dword file_offset; + dword reloc_addr; +} VAVLE_SECTIONS; + typedef struct dll_user_s { void *hInstance; // to avoid possible hacks qboolean custom_loader; // a bit who indicated loader type + qboolean encrypted; // dll is crypted (some client.dll in HL, CS etc) char dllName[32]; // for debug messages string fullPath, shortPath; // actual dll paths diff --git a/launch/system.c b/launch/system.c index eeafee42..991f70b0 100644 --- a/launch/system.c +++ b/launch/system.c @@ -15,11 +15,9 @@ system_t Sys; stdlib_api_t com; -launch_exp_t *Host; // callback to mainframe sys_event_t event_que[MAX_QUED_EVENTS]; int event_head, event_tail; -dll_info_t utils_dll = { "utils.dll", NULL, "CreateAPI", NULL, NULL, 1, sizeof( launch_exp_t ), sizeof( stdlib_api_t ) }; dll_info_t engine_dll = { "engine.dll", NULL, "CreateAPI", NULL, NULL, 1, sizeof( launch_exp_t ), sizeof( stdlib_api_t ) }; static const char *show_credits = "\n\n\n\n\tCopyright XashXT Group %s ©\n\t\ @@ -382,28 +380,28 @@ void Sys_LookupInstance( void ) else if( !com.strcmp( Sys.progname, "bsplib" )) { Sys.app_name = HOST_BSPLIB; - Sys.linked_dll = &utils_dll; // pointer to common.dll info + Sys.linked_dll = NULL; // no need to loading library com.strcpy( Sys.log_path, "bsplib.log" ); // xash3d root directory com.strcpy( Sys.caption, "Xash3D BSP Compiler"); } else if( !com.strcmp( Sys.progname, "sprite" )) { Sys.app_name = HOST_SPRITE; - Sys.linked_dll = &utils_dll; // pointer to common.dll info + Sys.linked_dll = NULL; // no need to loading library com.sprintf( Sys.log_path, "%s/spritegen.log", sys_rootdir ); // same as .exe file com.strcpy( Sys.caption, "Xash3D Sprite Compiler"); } else if( !com.strcmp( Sys.progname, "studio" )) { Sys.app_name = HOST_STUDIO; - Sys.linked_dll = &utils_dll; // pointer to common.dll info + Sys.linked_dll = NULL; // no need to loading library com.sprintf( Sys.log_path, "%s/studiomdl.log", sys_rootdir ); // same as .exe file com.strcpy( Sys.caption, "Xash3D Studio Models Compiler" ); } else if( !com.strcmp( Sys.progname, "wadlib" )) { Sys.app_name = HOST_WADLIB; - Sys.linked_dll = &utils_dll; // pointer to common.dll info + Sys.linked_dll = NULL; // no need to loading library com.sprintf( Sys.log_path, "%s/wadlib.log", sys_rootdir ); // same as .exe file com.strcpy( Sys.caption, "Xash3D Wad2\\Wad3 maker" ); } @@ -412,7 +410,7 @@ void Sys_LookupInstance( void ) Sys.app_name = HOST_RIPPER; Sys.con_readonly = true; Sys.log_active = true; // always create log - Sys.linked_dll = &utils_dll; // pointer to wdclib.dll info + Sys.linked_dll = NULL; // no need to loading library com.sprintf( Sys.log_path, "%s/decompile.log", sys_rootdir ); // default com.strcpy( Sys.caption, va("Quake Recource Extractor ver.%g", XASH_VERSION )); } @@ -420,7 +418,7 @@ void Sys_LookupInstance( void ) { Sys.app_name = HOST_XIMAGE; Sys.con_readonly = true; - Sys.linked_dll = &utils_dll; // pointer to dpvenc.dll info + Sys.linked_dll = NULL; // no need to loading library com.sprintf( Sys.log_path, "%s/image.log", sys_rootdir ); // logs folder com.strcpy( Sys.caption, "Image Processing Tool" ); } @@ -437,7 +435,8 @@ Find needed library, setup and run it void Sys_CreateInstance( void ) { // export - launch_t CreateHost; + launch_t CreateHost; + launch_exp_t *Host; // callback to mainframe srand( time( NULL )); // init random generator Sys_LoadLibrary( NULL, Sys.linked_dll ); // loading library if need @@ -447,12 +446,6 @@ void Sys_CreateInstance( void ) { case HOST_NORMAL: case HOST_DEDICATED: - case HOST_XIMAGE: - case HOST_BSPLIB: - case HOST_SPRITE: - case HOST_STUDIO: - case HOST_WADLIB: - case HOST_RIPPER: CreateHost = (void *)Sys.linked_dll->main; Host = CreateHost( &com, NULL ); // second interface not allowed Sys.Init = Host->Init; @@ -462,6 +455,19 @@ void Sys_CreateInstance( void ) Sys.CmdFwd = Host->CmdForward; Sys.CmdAuto = Host->CmdComplete; break; + case HOST_XIMAGE: + case HOST_BSPLIB: + case HOST_SPRITE: + case HOST_STUDIO: + case HOST_WADLIB: + case HOST_RIPPER: + Sys.Init = Init_Tools; + Sys.Main = Tools_Main; + Sys.Free = Free_Tools; + Sys.CPrint = Bsp_PrintLog; + Sys.CmdFwd = NULL; + Sys.CmdAuto = NULL; + break; case HOST_CREDITS: Sys_Break( show_credits, com.timestamp( TIME_YEAR_ONLY )); break; @@ -1442,4 +1448,27 @@ qboolean REG_SetValue( HKEY hKey, const char *SubKey, const char *Value, char *p RegCloseKey(hKey); } return true; +} + +// main DLL entry point +BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) +{ + return TRUE; +} + +/* +================= +Main Entry Point +================= +*/ +EXPORT int CreateAPI( const char *hostname, qboolean console ) +{ + com_strncpy( Sys.progname, hostname, sizeof( Sys.progname )); + Sys.hooked_out = console; + + Sys_Init(); + Sys.Main(); + Sys_Exit(); + + return 0; } \ No newline at end of file diff --git a/utils/badimage.h b/launch/tools/badimage.h similarity index 100% rename from utils/badimage.h rename to launch/tools/badimage.h diff --git a/utils/bsplib.c b/launch/tools/bsplib.c similarity index 100% rename from utils/bsplib.c rename to launch/tools/bsplib.c diff --git a/utils/ripper/conv_bsplumps.c b/launch/tools/conv_bsp.c similarity index 92% rename from utils/ripper/conv_bsplumps.c rename to launch/tools/conv_bsp.c index 9c242eae..c0a68fa9 100644 --- a/utils/ripper/conv_bsplumps.c +++ b/launch/tools/conv_bsp.c @@ -1,8 +1,9 @@ //======================================================================= // Copyright XashXT Group 2007 © -// conv_bsplumps.c - convert bsp lumps +// conv_bsp.c - convert bsp lumps //======================================================================= +#include "launch.h" #include "ripper.h" #include "wadfile.h" #include "byteorder.h" @@ -141,7 +142,7 @@ qboolean MipExist( const char *name ) if( !com.stricmp( name, mipnames[i].name )) return true; } - return FS_FileExists( name ); + return FS_FileExists( name, false ); } static const char *DetailTextureForName( const char *name ) @@ -221,9 +222,9 @@ void Conv_BspTextures( const char *name, dlump_t *l, const char *ext ) m->nummiptex = LittleLong( m->nummiptex ); dofs = m->dataofs; - detail_txt = FS_Open( va( "%s/%s_detail.txt", gs_gamedir, name ), "wb" ); + detail_txt = FS_Open( va( "%s/%s_detail.txt", gs_gamedir, name ), "wb", false ); - mipnames = Mem_Realloc( basepool, mipnames, m->nummiptex * sizeof( dmiptexname_t )); + mipnames = Mem_Realloc( Sys.basepool, mipnames, m->nummiptex * sizeof( dmiptexname_t )); mip_count = 0; // first pass: store all names into linear array @@ -266,7 +267,7 @@ void Conv_BspTextures( const char *name, dlump_t *l, const char *ext ) size = (int)sizeof(mip_t) + (((mip->width * mip->height) * 85)>>6); if( bsp_halflife ) size += sizeof(short) + 768; // palette - if( !FS_FileExists( va( "%s/%s/%s.%s", gs_gamedir, name, mip->name, ext ))) + if( !FS_FileExists( va( "%s/%s/%s.%s", gs_gamedir, name, mip->name, ext ), false )) ConvMIP( va("%s/%s", name, mip->name ), buffer, size, ext ); // convert it } @@ -310,7 +311,7 @@ qboolean ConvBSP( const char *name, byte *buffer, size_t filesize, const char *e qboolean Conv_CheckMap( const char *mapname ) { - file_t *f = FS_Open( mapname, "rb" ); + file_t *f = FS_Open( mapname, "rb", false ); gbsphdr_t hdr; // generic header if( !f ) return false; @@ -364,12 +365,12 @@ qboolean Conv_CheckMap( const char *mapname ) qboolean Conv_CheckWad( const char *wadname ) { - file_t *f = FS_Open( wadname, "rb" ); + file_t *f = FS_Open( wadname, "rb", false ); dwadheader_t hdr; // generic header if( !f ) return false; - if(FS_Read( f, &hdr, sizeof(dwadheader_t)) != sizeof(dwadheader_t)) + if(FS_Read( f, &hdr, sizeof( dwadheader_t )) != sizeof( dwadheader_t )) { FS_Close( f ); // very strange file with size smaller than 12 bytes and ext .wad return false; diff --git a/launch/tools/conv_image.c b/launch/tools/conv_image.c new file mode 100644 index 00000000..b1ff6b78 --- /dev/null +++ b/launch/tools/conv_image.c @@ -0,0 +1,503 @@ +//======================================================================= +// Copyright XashXT Group 2008 © +// conv_image.c - convert various image type +//======================================================================= + +#include "ripper.h" + +// doom spritemodel_qc +typedef struct angled_s +{ + char name[10]; // copy of skin name + + int width; // lumpwidth + int height; // lumpheight + int origin[2]; // monster origin + byte xmirrored; // swap left and right +} angled_t; + +struct angledframe_s +{ + angled_t frame[8]; // angled group or single frame + int bounds[2]; // group or frame maxsizes + byte angledframes; // count of angled frames max == 8 + byte normalframes; // count of anim frames max == 1 + byte mirrorframes; // animation mirror stored + + char membername[8]; // current model name, four characters + char animation; // current animation number + qboolean in_progress; // current state + file_t *f; // skin script +} flat; + +static void Skin_RoundDimensions( int *scaled_width, int *scaled_height ) +{ + int width, height; + + for( width = 1; width < *scaled_width; width <<= 1 ); + for( height = 1; height < *scaled_height; height <<= 1 ); + + *scaled_width = bound( 1, width, 512 ); + *scaled_height = bound( 1, height, 512 ); +} + +void Skin_WriteSequence( void ) +{ + int i; + + Skin_RoundDimensions( &flat.bounds[0], &flat.bounds[1] ); + + // time to dump frames :) + if( flat.angledframes == 8 ) + { + // angled group is full, dump it! + FS_Print( flat.f, "\n$angled\n{\n" ); + FS_Printf( flat.f, "\t// frame '%c'\n", flat.frame[0].name[4] ); + FS_Printf( flat.f, "\t$resample\t\t%d %d\n", flat.bounds[0], flat.bounds[1] ); + for( i = 0; i < 8; i++) + { + FS_Printf( flat.f,"\t$load\t\t%s.bmp", flat.frame[i].name ); + if( flat.frame[i].xmirrored ) FS_Print( flat.f," flip_x\n"); + else FS_Print( flat.f, "\n" ); + FS_Printf( flat.f,"\t$frame\t\t0 0 %d %d", flat.frame[i].width, flat.frame[i].height ); + FS_Printf( flat.f, " 0.1 %d %d\n", flat.frame[i].origin[0], flat.frame[i].origin[1] ); + } + FS_Print( flat.f, "}\n" ); + } + else if( flat.normalframes == 1 ) + { + // single frame stored + FS_Print( flat.f, "\n" ); + FS_Printf( flat.f, "// frame '%c'\n", flat.frame[0].name[4] ); + FS_Printf( flat.f,"$resample\t\t%d %d\n", flat.bounds[0], flat.bounds[1] ); + FS_Printf( flat.f,"$load\t\t%s.bmp\n", flat.frame[0].name ); + FS_Printf( flat.f,"$frame\t\t0 0 %d %d", flat.frame[0].width, flat.frame[0].height ); + FS_Printf( flat.f, " 0.1 %d %d\n", flat.frame[0].origin[0], flat.frame[0].origin[1]); + } + + // drop mirror frames too + if( flat.mirrorframes == 8 ) + { + // mirrored group is always flipped + FS_Print( flat.f, "\n$angled\n{\n" ); + FS_Printf( flat.f, "\t//frame '%c' (mirror '%c')\n", flat.frame[0].name[6], flat.frame[0].name[4] ); + FS_Printf( flat.f, "\t$resample\t\t%d %d\n", flat.bounds[0], flat.bounds[1] ); + for( i = 2; i > -1; i-- ) + { + FS_Printf( flat.f,"\t$load\t\t%s.bmp flip_x\n", flat.frame[i].name ); + FS_Printf( flat.f,"\t$frame\t\t0 0 %d %d", flat.frame[i].width, flat.frame[i].height ); + FS_Printf( flat.f, " 0.1 %d %d\n", flat.frame[i].origin[0], flat.frame[i].origin[1] ); + } + for( i = 7; i > 2; i-- ) + { + FS_Printf( flat.f,"\t$load\t\t%s.bmp flip_x\n", flat.frame[i].name ); + FS_Printf( flat.f,"\t$frame\t\t0 0 %d %d", flat.frame[i].width, flat.frame[i].height ); + FS_Printf( flat.f, " 0.1 %d %d\n", flat.frame[i].origin[0], flat.frame[i].origin[1] ); + } + FS_Print( flat.f, "}\n" ); + } + + flat.bounds[0] = flat.bounds[1] = 0; + Mem_Set( &flat.frame, 0, sizeof( flat.frame )); + flat.angledframes = flat.normalframes = flat.mirrorframes = 0; // clear all +} + +void Skin_FindSequence( const char *name, rgbdata_t *pic ) +{ + uint headlen; + char num, header[10]; + + // create header from flat name + com.strncpy( header, name, 10 ); + headlen = com.strlen( name ); + + if( flat.animation != header[4] ) + { + // write animation + Skin_WriteSequence(); + flat.animation = header[4]; + } + + if( flat.animation == header[4] ) + { + // update bounds + if( flat.bounds[0] < pic->width ) flat.bounds[0] = pic->width; + if( flat.bounds[1] < pic->height) flat.bounds[1] = pic->height; + + // continue collect frames + if( headlen == 6 ) + { + num = header[5] - '0'; + if(num == 0) flat.normalframes++; // animation frame + if(num == 8) num = 0; // merge + flat.angledframes++; // angleframe stored + com.strncpy( flat.frame[num].name, header, 9 ); + flat.frame[num].width = pic->width; + flat.frame[num].height = pic->height; + flat.frame[num].origin[0] = pic->width>>1; // center + flat.frame[num].origin[1] = pic->height; // floor + flat.frame[num].xmirrored = false; + } + else if( headlen == 8 ) + { + // normal image + num = header[5] - '0'; + if(num == 8) num = 0; // merge + com.strncpy( flat.frame[num].name, header, 9 ); + flat.frame[num].width = pic->width; + flat.frame[num].height = pic->height; + flat.frame[num].origin[0] = pic->width>>1; // center + flat.frame[num].origin[1] = pic->height; // floor + flat.frame[num].xmirrored = false; + flat.angledframes++; // frame stored + + if( header[4] != header[6] ) + { + // mirrored groups + flat.mirrorframes++; + return; + } + + // mirrored image + num = header[7] - '0'; // angle it's a direct acess to group + if(num == 8) num = 0; // merge + com.strncpy( flat.frame[num].name, header, 9 ); + flat.frame[num].width = pic->width; + flat.frame[num].height = pic->height; + flat.frame[num].origin[0] = pic->width>>1; // center + flat.frame[num].origin[1] = pic->height; // floor + flat.frame[num].xmirrored = true; // it's mirror frame + flat.angledframes++; // frame stored + } + else Sys_Break( "Skin_CreateScript: invalid name %s\n", name ); // this never happens + } +} + +void Skin_ProcessScript( const char *wad, const char *name ) +{ + if( flat.in_progress ) + { + // finish script + Skin_WriteSequence(); + FS_Close( flat.f ); + flat.in_progress = false; + } + if( !flat.in_progress ) + { + // start from scratch + com.strncpy( flat.membername, name, 5 ); + flat.f = FS_Open( va( "%s/%s/%s.qc", gs_gamedir, wad, flat.membername ), "w" ); + flat.in_progress = true; + flat.bounds[0] = flat.bounds[1] = 0; + + // write description + FS_Print( flat.f,"//=======================================================================\n"); + FS_Printf( flat.f,"//\t\t\tCopyright XashXT Group %s ©\n", timestamp( TIME_YEAR_ONLY )); + FS_Print( flat.f,"//\t\t\twritten by Xash Miptex Decompiler\n"); + FS_Print( flat.f,"//=======================================================================\n"); + + // write sprite header + FS_Printf( flat.f, "\n$spritename\t%s.spr\n", flat.membername ); + FS_Print( flat.f, "$type\t\tfacing_upright\n" ); // constant + FS_Print( flat.f, "$texture\t\talphatest\n"); + FS_Print( flat.f, "$noresample\n" ); // comment this command by taste + } +} + +// close sequence for unexpected concessions +void Skin_FinalizeScript( void ) +{ + if( !flat.in_progress ) return; + + // finish script + Skin_WriteSequence(); + FS_Close( flat.f ); + flat.in_progress = false; +} + +void Skin_CreateScript( const char *name, rgbdata_t *pic ) +{ + string skinname, wadname; + + FS_ExtractFilePath( name, wadname ); // wad name + FS_FileBase( name, skinname ); // skinname + + if(com.strnicmp( skinname, flat.membername, 4 )) + Skin_ProcessScript( wadname, skinname ); + + if( flat.in_progress ) + Skin_FindSequence( skinname, pic ); +} + +void Conv_WriteQCScript( const char *imagepath, rgbdata_t *p ) +{ + file_t *f = NULL; + string qcname, qcpath; + string temp, lumpname; + + // write also wadlist.qc for xwad compiler + FS_ExtractFilePath( imagepath, temp ); + FS_FileBase( imagepath, lumpname ); + FS_FileBase( temp, qcname ); + FS_DefaultExtension( qcname, ".qc" ); + com.snprintf( qcpath, MAX_STRING, "%s/%s/$%s", gs_gamedir, temp, qcname ); + + if( write_qscsript ) + { + if( FS_FileExists( qcpath )) + { + script_t *test; + token_t token; + + // already exist, search for current name + test = Com_OpenScript( qcpath, NULL, 0 ); + while( Com_ReadToken( test, SC_ALLOW_NEWLINES|SC_PARSE_GENERIC, &token )) + { + if( !com.stricmp( token.string, "$mipmap" )) + { + Com_ReadToken( test, SC_PARSE_GENERIC, &token ); + if( !com.stricmp( token.string, lumpname )) + { + Com_CloseScript( test ); + return; // already exist + } + } + Com_SkipRestOfLine( test ); + } + Com_CloseScript( test ); + f = FS_Open( qcpath, "a" ); // append + } + else + { + FS_StripExtension( qcname ); // no need anymore + f = FS_Open( qcpath, "w" ); // new file + // write description + FS_Print(f,"//=======================================================================\n"); + FS_Printf(f,"//\t\t\tCopyright XashXT Group %s ©\n", timestamp( TIME_YEAR_ONLY )); + FS_Print(f,"//\t\t\twritten by Xash Miptex Decompiler\n"); + FS_Print(f,"//=======================================================================\n"); + FS_Printf(f,"$wadname\t%s.wad\n\n", qcname ); + } + + if( f && p ) + { + if( !com.stricmp( FS_FileExtension( imagepath ), "lmp" )) + FS_Printf( f,"$gfxpic\t%s\t0 0 %d %d\n", lumpname, p->width, p->height ); + else FS_Printf( f,"$mipmap\t%s\t0 0 %d %d\n", lumpname, p->width, p->height ); + if( p->flags & IMAGE_HAS_LUMA ) // also add luma image if present + FS_Printf( f,"$mipmap\t%s_luma\t0 0 %d %d\n", lumpname, p->width, p->height ); + FS_Close( f ); // all done + } + } +} + +/* +============ +ConvSKN +============ +*/ +qboolean ConvSKN( const char *name, byte *buffer, size_t filesize, const char *ext ) +{ + rgbdata_t *pic = FS_LoadImage( va( "#%s.flt", name ), buffer, filesize ); + + if( pic ) + { + FS_SaveImage( va("%s/%s.%s", gs_gamedir, name, ext ), pic ); + Skin_CreateScript( name, pic ); + Msg( "%s.flat\n", name ); // echo to console + FS_FreeImage( pic ); + return true; + } + return false; +} + +/* +============ +ConvFLP +============ +*/ +qboolean ConvFLP( const char *name, byte *buffer, size_t filesize, const char *ext ) +{ + rgbdata_t *pic = FS_LoadImage( va( "#%s.flt", name ), buffer, filesize ); + + if( pic ) + { + FS_SaveImage(va("%s/%s.%s", gs_gamedir, name, ext ), pic ); + Msg( "%s.flat\n", name ); // echo to console + FS_FreeImage( pic ); + return true; + } + return false; +} + +/* +============ +ConvFLT +============ +*/ +qboolean ConvFLT( const char *name, byte *buffer, size_t filesize, const char *ext ) +{ + rgbdata_t *pic = FS_LoadImage( va( "#%s.flt", name ), buffer, filesize ); + + if( pic ) + { + string savedname, tempname, path; + + if( pic->flags & IMAGE_HAS_ALPHA ) + { + // insert '{' symbol for transparency textures + FS_ExtractFilePath( name, path ); + FS_FileBase( name, tempname ); + com.snprintf( savedname, MAX_STRING, "%s/{%s", path, tempname ); + } + else com.strncpy( savedname, name, MAX_STRING ); + + FS_SaveImage( va("%s/%s.%s", gs_gamedir, savedname, ext ), pic ); + Conv_WriteQCScript( savedname, pic ); + Msg( "%s.flat\n", savedname ); // echo to console + FS_FreeImage( pic ); + return true; + } + return false; +} + +/* +============ +ConvWAL +============ +*/ +qboolean ConvWAL( const char *name, byte *buffer, size_t filesize, const char *ext ) +{ + rgbdata_t *pic = FS_LoadImage( va( "#%s.wal", name ), buffer, filesize ); + + if( pic ) + { + FS_SaveImage( va("%s/%s.%s", gs_gamedir, name, ext ), pic ); + Conv_WriteQCScript( name, pic ); + Msg("%s.wal\n", name ); // echo to console + FS_FreeImage( pic ); + return true; + } + return false; +} + +/* +============= +ConvBMP +============= +*/ +qboolean ConvBMP( const char *name, byte *buffer, size_t filesize, const char *ext ) +{ + rgbdata_t *pic = FS_LoadImage( va( "#%s.bmp", name ), buffer, filesize ); + + if( pic ) + { + FS_SaveImage( va("%s/%s.%s", gs_gamedir, name, ext ), pic ); + Conv_WriteQCScript( name, pic ); + Msg( "%s.bmp\n", name, ext ); // echo to console + FS_FreeImage( pic ); + return true; + } + return false; +} + +/* +============= +ConvPCX + +this also uses by SP2_ConvertFrame +============= +*/ +qboolean ConvPCX( const char *name, byte *buffer, size_t filesize, const char *ext ) +{ + rgbdata_t *pic = FS_LoadImage( va( "#%s.pcx", name ), buffer, filesize ); + + if( pic ) + { + FS_SaveImage( va("%s/%s.%s", gs_gamedir, name, ext ), pic ); + Msg( "%s.pcx\n", name ); // echo to console + FS_FreeImage( pic ); + return true; + } + return false; +} + +/* +============= +ConvVTF +============= +*/ +qboolean ConvVTF( const char *name, byte *buffer, size_t filesize, const char *ext ) +{ + rgbdata_t *pic = FS_LoadImage( va( "#%s.vtf", name ), buffer, filesize ); + + if( pic ) + { + FS_SaveImage( va("%s/%s.%s", gs_gamedir, name, ext ), pic ); + Conv_WriteQCScript( name, pic ); + Msg( "%s.vtf\n", name ); // echo to console + FS_FreeImage( pic ); + return true; + } + return false; +} + +/* +============ +ConvMIP +============ +*/ +qboolean ConvMIP( const char *name, byte *buffer, size_t filesize, const char *ext ) +{ + rgbdata_t *pic = FS_LoadImage( va( "#%s.mip", name ), buffer, filesize ); + + if( pic ) + { + FS_SaveImage( va("%s/%s.%s", gs_gamedir, name, ext ), pic ); + Conv_WriteQCScript( name, pic ); + Msg( "%s.mip\n", name ); // echo to console + FS_FreeImage( pic ); + return true; + } + return false; +} + +/* +============ +ConvLMP +============ +*/ +qboolean ConvLMP( const char *name, byte *buffer, size_t filesize, const char *ext ) +{ + rgbdata_t *pic = FS_LoadImage( va( "#%s.lmp", name ), buffer, filesize ); + + if( pic ) + { + FS_SaveImage(va("%s/%s.%s", gs_gamedir, name, ext ), pic ); + Conv_WriteQCScript( va( "%s.lmp", name ), pic ); + Msg("%s.lmp\n", name ); // echo to console + FS_FreeImage( pic ); + return true; + } + return false; +} + +/* +============ +ConvFNT +============ +*/ +qboolean ConvFNT( const char *name, byte *buffer, size_t filesize, const char *ext ) +{ + rgbdata_t *pic = FS_LoadImage( va( "#%s.fnt", name ), buffer, filesize ); + + if( pic ) + { + FS_SaveImage(va("%s/%s.%s", gs_gamedir, name, ext ), pic ); + Conv_WriteQCScript( name, pic ); + Msg("%s.fnt\n", name ); // echo to console + FS_FreeImage( pic ); + return true; + } + return false; +} \ No newline at end of file diff --git a/utils/ripper/conv_main.c b/launch/tools/conv_main.c similarity index 78% rename from utils/ripper/conv_main.c rename to launch/tools/conv_main.c index a945f12f..361c0759 100644 --- a/utils/ripper/conv_main.c +++ b/launch/tools/conv_main.c @@ -18,41 +18,39 @@ typedef struct convformat_s convformat_t convert_formats[] = { - {"%s.%s", "spr", ConvSPR, "bmp" }, // quake1/half-life sprite - {"%s.%s","spr32",ConvSPR, "tga" }, // spr32 sprite - {"%s.%s", "sp2", ConvSPR, "bmp" }, // quake2 sprite - {"%s.%s", "pcx", ConvPCX, "bmp" }, // quake2 pics - {"%s.%s", "flt", ConvFLT, "bmp" }, // doom1 textures - {"%s.%s", "flp", ConvFLP, "bmp" }, // doom1 menu pics - {"%s.%s", "mip", ConvMIP, "bmp" }, // Quake1/Half-Life textures - {"%s.%s", "lmp", ConvLMP, "bmp" }, // Quake1/Half-Life gfx - {"%s.%s", "fnt", ConvFNT, "bmp" }, // Quake1/Half-Life gfx - {"%s.%s", "wal", ConvWAL, "bmp" }, // Quake2 textures - {"%s.%s", "vtf", ConvVTF, "dds" }, // Half-Life 2 materials - {"%s.%s", "skn", ConvSKN, "bmp" }, // doom1 sprite models - {"%s.%s", "bsp", ConvBSP, "bmp" }, // Quake1\Half-Life map textures - {"%s.%s", "mus", ConvMID, "mid" }, // doom1\2 music files - {NULL, NULL, NULL, NULL } // list terminator +{"%s.%s", "spr", ConvSPR, "bmp" }, // quake1/half-life sprite +{"%s.%s","spr32",ConvSPR, "tga" }, // spr32 sprite +{"%s.%s", "sp2", ConvSPR, "bmp" }, // quake2 sprite +{"%s.%s", "pcx", ConvPCX, "bmp" }, // quake2 pics +{"%s.%s", "flt", ConvFLT, "bmp" }, // doom1 textures +{"%s.%s", "flp", ConvFLP, "bmp" }, // doom1 menu pics +{"%s.%s", "mip", ConvMIP, "bmp" }, // Quake1/Half-Life textures +{"%s.%s", "lmp", ConvLMP, "bmp" }, // Quake1/Half-Life gfx +{"%s.%s", "fnt", ConvFNT, "bmp" }, // Quake1/Half-Life gfx +{"%s.%s", "wal", ConvWAL, "bmp" }, // Quake2 textures +{"%s.%s", "vtf", ConvVTF, "dds" }, // Half-Life 2 materials +{"%s.%s", "skn", ConvSKN, "bmp" }, // doom1 sprite models +{"%s.%s", "bsp", ConvBSP, "bmp" }, // Quake1\Half-Life map textures +{NULL, NULL, NULL, NULL } // list terminator }; convformat_t convert_formats32[] = { - {"%s.%s", "spr", ConvSPR, "tga" }, // quake1/half-life sprite - {"%s.%s","spr32",ConvSPR, "dds" }, // spr32 sprite - {"%s.%s", "sp2", ConvSPR, "dds" }, // quake2 sprite - {"%s.%s", "bmp", ConvBMP, "dds" }, // 8-bit maps with alpha-cnahnel - {"%s.%s", "pcx", ConvPCX, "tga" }, // quake2 pics - {"%s.%s", "flt", ConvFLT, "tga" }, // doom1 textures - {"%s.%s", "flp", ConvFLP, "tga" }, // doom1 menu pics - {"%s.%s", "mip", ConvMIP, "tga" }, // Quake1/Half-Life textures - {"%s.%s", "lmp", ConvLMP, "tga" }, // Quake1/Half-Life gfx - {"%s.%s", "fnt", ConvFNT, "tga" }, // Quake1/Half-Life gfx - {"%s.%s", "wal", ConvWAL, "tga" }, // Quake2 textures - {"%s.%s", "vtf", ConvVTF, "dds" }, // Half-Life 2 materials - {"%s.%s", "skn", ConvSKN, "tga" }, // doom1 sprite models - {"%s.%s", "bsp", ConvBSP, "tga" }, // Quake1\Half-Life map textures - {"%s.%s", "mus", ConvMID, "mid" }, // doom1\2 music files - {NULL, NULL, NULL, NULL } // list terminator +{"%s.%s", "spr", ConvSPR, "tga" }, // quake1/half-life sprite +{"%s.%s","spr32",ConvSPR, "dds" }, // spr32 sprite +{"%s.%s", "sp2", ConvSPR, "dds" }, // quake2 sprite +{"%s.%s", "bmp", ConvBMP, "dds" }, // 8-bit maps with alpha-cnahnel +{"%s.%s", "pcx", ConvPCX, "tga" }, // quake2 pics +{"%s.%s", "flt", ConvFLT, "tga" }, // doom1 textures +{"%s.%s", "flp", ConvFLP, "tga" }, // doom1 menu pics +{"%s.%s", "mip", ConvMIP, "tga" }, // Quake1/Half-Life textures +{"%s.%s", "lmp", ConvLMP, "tga" }, // Quake1/Half-Life gfx +{"%s.%s", "fnt", ConvFNT, "tga" }, // Quake1/Half-Life gfx +{"%s.%s", "wal", ConvWAL, "tga" }, // Quake2 textures +{"%s.%s", "vtf", ConvVTF, "dds" }, // Half-Life 2 materials +{"%s.%s", "skn", ConvSKN, "tga" }, // doom1 sprite models +{"%s.%s", "bsp", ConvBSP, "tga" }, // Quake1\Half-Life map textures +{NULL, NULL, NULL, NULL } // list terminator }; qboolean CheckForExist( const char *path, const char *ext ) @@ -75,7 +73,7 @@ qboolean ConvertResource( byte *mempool, const char *filename, byte parms ) { convformat_t *format; const char *ext = FS_FileExtension( filename ); - qboolean anyformat = !com.stricmp(ext, "") ? true : false; + qboolean anyformat = !com.stricmp( ext, "" ) ? true : false; string path, convname, basename; int filesize = 0; byte *buffer = NULL; @@ -107,6 +105,7 @@ qboolean ConvertResource( byte *mempool, const char *filename, byte parms ) if( buffer ) Mem_Free( buffer ); // release buffer } } + FS_FileBase( convname, basename ); MsgDev( D_WARN, "ConvertResource: couldn't load \"%s\"\n", basename ); return false; @@ -194,7 +193,6 @@ void Conv_RunSearch( void ) } Image_Init( "Doom1", imageflags ); break; - case GAME_HEXEN2: case GAME_QUAKE1: search = FS_Search("*.wad", true ); // make sure, that we stored all files from all wads diff --git a/utils/ripper/conv_sprite.c b/launch/tools/conv_sprite.c similarity index 94% rename from utils/ripper/conv_sprite.c rename to launch/tools/conv_sprite.c index 75d0fd59..433167e9 100644 --- a/utils/ripper/conv_sprite.c +++ b/launch/tools/conv_sprite.c @@ -3,6 +3,7 @@ // conv_sprite.c - convert q1\q2\hl\spr32 sprites //======================================================================= +#include "launch.h" #include "ripper.h" #include "byteorder.h" #include "sprite.h" @@ -170,14 +171,14 @@ void *SPR_ConvertFrame( const char *name, const char *ext, void *pin, int framen if( spr.truecolor ) pixels *= 4; // frame exist, go next - if( FS_FileExists( va("%s/sprites/%s.%s", gs_gamedir, framename, ext ))) + if( FS_FileExists( va("%s/sprites/%s.%s", gs_gamedir, framename, ext ), false )) return (void *)((byte *)(pinframe + 1) + pixels ); if( spr.truecolor ) { // HACKHACK: manually create rgbdata_t - pix = Mem_Alloc( basepool, sizeof( *pix )); - fout = Mem_Alloc( basepool, pixels ); + pix = Mem_Alloc( Sys.basepool, sizeof( *pix )); + fout = Mem_Alloc( Sys.basepool, pixels ); Mem_Copy( fout, fin, pixels ); if( spr.texFormat >= SPR_INDEXALPHA ) pix->flags |= IMAGE_HAS_ALPHA; @@ -234,7 +235,7 @@ qboolean SP2_ConvertFrame( const char *name, const char *ext, int framenum ) com.strncpy( barename, name, MAX_STRING ); FS_StripExtension( barename ); - if( FS_FileExists( va("%s/%s.%s", gs_gamedir, barename, ext ))) + if( FS_FileExists( va("%s/%s.%s", gs_gamedir, barename, ext ), false )) return true; fin = FS_LoadFile( name, &filesize ); @@ -283,9 +284,9 @@ qboolean SPR_WriteScript( const char *name, const char *ext ) file_t *f; FS_FileBase( name ,shortname ); - if( FS_FileExists( va("%s/sprites/%s.qc", gs_gamedir, shortname ))) + if( FS_FileExists( va("%s/sprites/%s.qc", gs_gamedir, shortname ), false )) return true; - f = FS_Open( va("%s/sprites/%s.qc", gs_gamedir, shortname ), "w" ); + f = FS_Open( va("%s/sprites/%s.qc", gs_gamedir, shortname ), "w", false ); if( !f ) { @@ -295,7 +296,7 @@ qboolean SPR_WriteScript( const char *name, const char *ext ) // description FS_Printf(f,"//=======================================================================\n"); - FS_Printf(f,"//\t\t\tCopyright XashXT Group %s ©\n", timestamp( TIME_YEAR_ONLY )); + FS_Printf(f,"//\t\t\tCopyright XashXT Group %s ©\n", com.timestamp( TIME_YEAR_ONLY )); FS_Printf(f,"//\t\t\twritten by Xash Miptex Decompiler\n", name ); FS_Printf(f,"//=======================================================================\n"); diff --git a/utils/mdllib.h b/launch/tools/mdllib.h similarity index 94% rename from utils/mdllib.h rename to launch/tools/mdllib.h index 57a0a635..982b98a2 100644 --- a/utils/mdllib.h +++ b/launch/tools/mdllib.h @@ -9,6 +9,7 @@ #include "studio.h" #include "mathlib.h" +#define ALIGN( a ) a = (byte *)((int)((byte *)a + 3) & ~ 3) #define FILEBUFFER (1024 * 1024 * 16) // 16 megs filebuffer #define FLOAT_START 99999.0 #define FLOAT_END -99999.0 diff --git a/utils/ripper/ripper.h b/launch/tools/ripper.h similarity index 91% rename from utils/ripper/ripper.h rename to launch/tools/ripper.h index 63a39914..724938f8 100644 --- a/utils/ripper/ripper.h +++ b/launch/tools/ripper.h @@ -8,7 +8,6 @@ #include "utils.h" extern stdlib_api_t com; -extern byte *basepool; extern string gs_gamedir; #define Sys_Error com.error extern uint app_name; @@ -16,7 +15,6 @@ extern qboolean write_qscsript; extern int game_family; // common tools -qboolean Conv_CreateShader( const char *name, rgbdata_t *pic, const char *ext, const char *anim, int surf, int cnt ); qboolean Conv_CheckMap( const char *mapname ); // for detect gametype qboolean Conv_CheckWad( const char *wadname ); // for detect gametype qboolean MipExist( const char *name ); diff --git a/utils/spritegen.c b/launch/tools/spritegen.c similarity index 100% rename from utils/spritegen.c rename to launch/tools/spritegen.c diff --git a/utils/studio.c b/launch/tools/studio.c similarity index 100% rename from utils/studio.c rename to launch/tools/studio.c diff --git a/utils/studio_utils.c b/launch/tools/studio_utils.c similarity index 100% rename from utils/studio_utils.c rename to launch/tools/studio_utils.c diff --git a/utils/utils.c b/launch/tools/tools.c similarity index 77% rename from utils/utils.c rename to launch/tools/tools.c index 1340f936..3032914a 100644 --- a/utils/utils.c +++ b/launch/tools/tools.c @@ -3,6 +3,7 @@ // platform.c - tools common dll //======================================================================= +#include "launch.h" #include "utils.h" #include "mdllib.h" #include "engine_api.h" @@ -20,12 +21,9 @@ string gs_searchmask; string gs_gamedir; string gs_basedir; string gs_filename; -byte *basepool; -byte *zonepool; byte *error_bmp; size_t error_bmp_size; static double start, end; -uint app_name = HOST_OFFLINE; qboolean enable_log = false; file_t *bsplog = NULL; @@ -90,26 +88,22 @@ qboolean Com_ValidScript( const char *token, qctype_t scripttype ) /* ================== -CommonInit +Init_Tools -launch.dll needs for some setup operations -so do it manually ================== */ -void InitCommon( const int argc, const char **argv ) +void Init_Tools( const int argc, const char **argv ) { int imageflags = 0; - basepool = Mem_AllocPool( "Common Pool" ); - app_name = g_Instance(); enable_log = false; - switch( app_name ) + switch( Sys.app_name ) { case HOST_BSPLIB: - if( !FS_GetParmFromCmdLine( "-game", gs_basedir )) + if( !FS_GetParmFromCmdLine( "-game", gs_basedir, sizeof( gs_basedir ))) com.strncpy( gs_basedir, Cvar_VariableString( "fs_defaultdir" ), sizeof( gs_basedir )); - if( !FS_GetParmFromCmdLine( "+map", gs_filename )) + if( !FS_GetParmFromCmdLine( "+map", gs_filename, sizeof( gs_filename ))) com.strncpy( gs_filename, "newmap", sizeof( gs_filename )); // initialize ImageLibrary start = Sys_DoubleTime(); @@ -118,7 +112,7 @@ void InitCommon( const int argc, const char **argv ) case HOST_XIMAGE: imageflags |= (IL_USE_LERPING|IL_ALLOW_OVERWRITE|IL_IGNORE_MIPS); com_argv = (char **)argv; - if( !FS_GetParmFromCmdLine( "-to", gs_filename )) + if( !FS_GetParmFromCmdLine( "-to", gs_filename, sizeof( gs_filename ))) { gs_filename[0] = '\0'; // will be set later } @@ -128,7 +122,7 @@ void InitCommon( const int argc, const char **argv ) if( !com.stricmp( gs_filename, "pcx" ) || !com.stricmp( gs_filename, "bmp" )) imageflags |= IL_KEEP_8BIT; } - Image_Init( NULL, imageflags ); + Image_Setup( NULL, imageflags ); FS_InitRootDir("."); start = Sys_DoubleTime(); @@ -138,7 +132,7 @@ void InitCommon( const int argc, const char **argv ) case HOST_STUDIO: case HOST_WADLIB: imageflags |= IL_KEEP_8BIT; - Image_Init( NULL, imageflags ); + Image_Setup( NULL, imageflags ); case HOST_RIPPER: // blamk image for missed resources error_bmp = (byte *)blank_bmp; @@ -153,7 +147,7 @@ void InitCommon( const int argc, const char **argv ) } } -void CommonMain( void ) +void Tools_Main( void ) { search_t *search; qboolean (*CompileMod)( byte *mempool, const char *name, byte parms ) = NULL; @@ -164,7 +158,7 @@ void CommonMain( void ) Mem_Set( errorstring, 0, MAX_STRING ); ClrMask(); - switch( app_name ) + switch( Sys.app_name ) { case HOST_SPRITE: CompileMod = CompileSpriteModel; @@ -195,12 +189,12 @@ void CommonMain( void ) if( !CompileMod ) goto elapced_time; // jump to shutdown // using custom mask - if( FS_GetParmFromCmdLine( "-file", gs_searchmask )) + if( FS_GetParmFromCmdLine( "-file", gs_searchmask, sizeof( gs_searchmask ))) { ClrMask(); // clear all previous masks AddMask( gs_searchmask ); // custom mask - if( app_name == HOST_XIMAGE && !gs_filename[0] ) + if( Sys.app_name == HOST_XIMAGE && !gs_filename[0] ) { const char *ext = FS_FileExtension( gs_searchmask ); @@ -208,7 +202,7 @@ void CommonMain( void ) else com.strncpy( gs_filename, ext, sizeof( gs_filename )); } } - zonepool = Mem_AllocPool( "Zone Pool" ); + Msg( "Converting ...\n\n" ); // search by mask @@ -216,12 +210,12 @@ void CommonMain( void ) { // skip blank mask if( !com.strlen( searchmask[i] )) continue; - search = FS_Search( searchmask[i], true ); + search = FS_Search( searchmask[i], true, false ); if( !search ) continue; // try next mask for( j = 0; j < search->numfilenames; j++ ) { - if( CompileMod( zonepool, search->filenames[j], parms )) + if( CompileMod( Sys.basepool, search->filenames[j], parms )) numCompiledMods++; } Mem_Free( search ); @@ -242,37 +236,15 @@ elapced_time: if( numCompiledMods > 1 ) Msg( "total %d files proceed\n", numCompiledMods ); } -void FreeCommon( void ) +void Free_Tools( void ) { - if( app_name == HOST_RIPPER ) + if( Sys.app_name == HOST_RIPPER ) { // finalize qc-script Skin_FinalizeScript(); } - else if( app_name == HOST_BSPLIB ) + else if( Sys.app_name == HOST_BSPLIB ) { if( bsplog ) FS_Close( bsplog ); } - - Mem_Check(); // check for leaks - Mem_FreePool( &basepool ); - Mem_FreePool( &zonepool ); -} - -launch_exp_t EXPORT *CreateAPI( stdlib_api_t *input, void *unused ) -{ - static launch_exp_t Com; - - com = *input; - - // generic functions - Com.api_size = sizeof( launch_exp_t ); - Com.com_size = sizeof( stdlib_api_t ); - - Com.Init = InitCommon; - Com.Main = CommonMain; - Com.Free = FreeCommon; - Com.CPrint = Bsp_PrintLog; - - return &Com; } \ No newline at end of file diff --git a/utils/utils.h b/launch/tools/utils.h similarity index 81% rename from utils/utils.h rename to launch/tools/utils.h index 286c87a3..e6e7b9c5 100644 --- a/utils/utils.h +++ b/launch/tools/utils.h @@ -9,17 +9,11 @@ #include #include "launch_api.h" -#define ALIGN( a ) a = (byte *)((int)((byte *)a + 3) & ~ 3) - -extern byte *basepool; -extern byte *zonepool; extern qboolean enable_log; extern stdlib_api_t com; extern file_t *bsplog; -#define Sys_Error com.error -#define Malloc( size ) Mem_Alloc( basepool, size ) -#define Realloc( ptr, size ) Mem_Realloc( basepool, ptr, size ) +#define Realloc( ptr, size ) Mem_Realloc( Sys.basepool, ptr, size ) extern string gs_filename; extern string gs_basedir; @@ -31,7 +25,6 @@ typedef enum { QC_SPRITEGEN = 1, QC_STUDIOMDL, - QC_ROQLIB, QC_WADLIB } qctype_t; diff --git a/utils/wadlib.c b/launch/tools/wadlib.c similarity index 84% rename from utils/wadlib.c rename to launch/tools/wadlib.c index ac569c79..4c76373f 100644 --- a/utils/wadlib.c +++ b/launch/tools/wadlib.c @@ -21,7 +21,7 @@ int color_used[256]; float maxdistortion; int colors_used; byte pixdata[256]; -rgbdata_t *image = NULL; +rgbdata_t *wadpic = NULL; vec3_t d_color; byte Pal_AddColor( float r, float g, float b ) @@ -37,13 +37,13 @@ byte Pal_AddColor( float r, float g, float b ) linearpalette[i][2] = b; if( r < 0.0 ) r = 0.0; if( r > 1.0 ) r = 1.0; - image->palette[i*3+0] = pow( r, 1.0 / 2.2) * 255; + wadpic->palette[i*3+0] = pow( r, 1.0 / 2.2) * 255; if( g < 0.0 ) g = 0.0; if( g > 1.0 ) g = 1.0; - image->palette[i*3+1] = pow( g, 1.0 / 2.2) * 255; + wadpic->palette[i*3+1] = pow( g, 1.0 / 2.2) * 255; if( b < 0.0 ) b = 0.0; if( b > 1.0 ) b = 1.0; - image->palette[i*3+2] = pow( b, 1.0 / 2.2) * 255; + wadpic->palette[i*3+2] = pow( b, 1.0 / 2.2) * 255; color_used[i] = 1; colors_used++; return i; @@ -170,12 +170,12 @@ void Cmd_GrabMip( void ) Com_ReadString( wadqc, SC_PARSE_GENERIC, lumpname ); - // load mip image - image = FS_LoadImage( lumpname, NULL, 0 ); - if( !image ) + // load mip wadpic + wadpic = FS_LoadImage( lumpname, NULL, 0 ); + if( !wadpic ) { Com_SkipRestOfLine( wadqc ); - // no fatal error, just ignore this image for adding into wad-archive + // no fatal error, just ignore this wadpic for adding into wad-archive MsgDev( D_ERROR, "Cmd_LoadMip: unable to loading %s\n", lumpname ); return; } @@ -191,19 +191,19 @@ void Cmd_GrabMip( void ) else { xl = yl = 0; - w = image->width; - h = image->height; + w = wadpic->width; + h = wadpic->height; } - // reflood image with new size + // reflood wadpic with new size if(( w & 15 ) || ( h & 15 )) flags |= IMAGE_ROUNDFILLER; - Image_Process( &image, 0, 0, flags ); + Image_Process( &wadpic, 0, 0, flags ); if( flags & IMAGE_ROUNDFILLER ) { - // updates image size - w = image->width; - h = image->height; + // updates wadpic size + w = wadpic->width; + h = wadpic->height; } xh = xl + w; @@ -221,8 +221,8 @@ void Cmd_GrabMip( void ) com.strncpy( mip->name, lumpname, sizeof(mip->name)); plump = (byte *)&mip->offsets[4]; - screen_p = image->buffer + yl * image->width + xl; - linedelta = image->width - w; + screen_p = wadpic->buffer + yl * wadpic->width + xl; + linedelta = wadpic->width - w; source = plump; mip->offsets[0] = LittleLong( plump - (byte *)mip ); @@ -241,13 +241,13 @@ void Cmd_GrabMip( void ) for( j = 0; j < 3; j++ ) { // assume textures are done at 2.2, we want to remap them at 1.0 - float f = image->palette[i*3+j] / 255.0; + float f = wadpic->palette[i*3+j] / 255.0; linearpalette[i][j] = pow( f, 2.2 ); } } maxdistortion = 0; - if(!(image->flags & IMAGE_HAS_ALPHA )) + if(!(wadpic->flags & IMAGE_HAS_ALPHA )) { // figure out what palette entries are actually used colors_used = 0; @@ -295,8 +295,8 @@ void Cmd_GrabMip( void ) testpixel = source[(y + yy) * w + x + xx]; // if 255 is not transparent, or this isn't - // a transparent pixel add it in to the image filter - if(!(image->flags & IMAGE_HAS_ALPHA ) || testpixel != 255) + // a transparent pixel add it in to the wadpic filter + if(!(wadpic->flags & IMAGE_HAS_ALPHA ) || testpixel != 255) { pixdata[count] = testpixel; count++; @@ -316,14 +316,14 @@ void Cmd_GrabMip( void ) // bounds checker if( plump + 768 == plump_end ) { - Mem_Copy( plump, image->palette, 768 ); + Mem_Copy( plump, wadpic->palette, 768 ); plump += 768; // write out and release intermediate buffers Wad3_AddLump( lump, plump_size, TYP_MIPTEX, wad_compress ); } else MsgDev( D_WARN, "lump %s have invalid size, ignore\n", lumpname ); - FS_FreeImage( image ); + FS_FreeImage( wadpic ); Mem_Free( lump ); } @@ -343,17 +343,17 @@ void Cmd_GrabPic( void ) Com_ReadString( wadqc, SC_PARSE_GENERIC, lumpname ); - // load lmp image - image = FS_LoadImage( lumpname, NULL, 0 ); - if( !image ) + // load lmp wadpic + wadpic = FS_LoadImage( lumpname, NULL, 0 ); + if( !wadpic ) { Com_SkipRestOfLine( wadqc ); - // no fatal error, just ignore this image for adding into wad-archive + // no fatal error, just ignore this wadpic for adding into wad-archive MsgDev( D_ERROR, "Cmd_LoadPic: unable to loading %s\n", lumpname ); return; } - Image_Process( &image, 0, 0, IMAGE_PALTO24 ); // turn into 24-bit mode + Image_Process( &wadpic, 0, 0, IMAGE_PALTO24 ); // turn into 24-bit mode if(Com_ReadUlong( wadqc, false, &xl )) { @@ -366,15 +366,15 @@ void Cmd_GrabPic( void ) else { xl = yl = 0; - xh = image->width; - yh = image->height; + xh = wadpic->width; + yh = wadpic->height; } if( xh < xl || yh < yl || xl < 0 || yl < 0 ) { xl = yl = 0; - xh = image->width; - yh = image->height; + xh = wadpic->width; + yh = wadpic->height; } // lmp_t + picture[w*h] + numcolors[short] + palette[768]; @@ -388,16 +388,16 @@ void Cmd_GrabPic( void ) plump = (byte *)(pic + 1); for( y = yl; y < yh; y++ ) for( x = xl; x < xh; x++ ) - *plump++ = (*(image->buffer + (y) * image->width + x)); + *plump++ = (*(wadpic->buffer + (y) * wadpic->width + x)); *(word*)plump = 256; // palette size plump += sizeof(short); - Mem_Copy( plump, image->palette, 768 ); + Mem_Copy( plump, wadpic->palette, 768 ); plump += 768; // write out and release intermediate buffers Wad3_AddLump( lump, plump_size, TYP_QPIC, wad_compress ); - FS_FreeImage( image ); + FS_FreeImage( wadpic ); Mem_Free( lump ); } diff --git a/utils/ximage.c b/launch/tools/ximage.c similarity index 100% rename from utils/ximage.c rename to launch/tools/ximage.c diff --git a/public/vsound_api.h b/public/vsound_api.h deleted file mode 100644 index 6bf5bc9d..00000000 --- a/public/vsound_api.h +++ /dev/null @@ -1,90 +0,0 @@ -//======================================================================= -// Copyright XashXT Group 2008 © -// vsound_api.h - xash sound engine (OpenAL based) -//======================================================================= -#ifndef VSOUND_API_H -#define VSOUND_API_H - -typedef int sound_t; - -typedef struct -{ - string name; - int entnum; - int entchannel; - vec3_t origin; - float volume; - float attenuation; - qboolean looping; - int pitch; -} soundlist_t; - -// sound flags -#define SND_VOLUME (1<<0) // a scaled byte -#define SND_ATTENUATION (1<<1) // a byte -#define SND_PITCH (1<<2) // a byte -#define SND_FIXED_ORIGIN (1<<3) // a vector -#define SND_SENTENCE (1<<4) // set if sound num is actually a sentence num -#define SND_STOP (1<<5) // stop the sound -#define SND_CHANGE_VOL (1<<6) // change sound vol -#define SND_CHANGE_PITCH (1<<7) // change sound pitch -#define SND_SPAWNING (1<<8) // we're spawning, used in some cases for ambients - -/* -============================================================================== - -VSOUND.DLL INTERFACE -============================================================================== -*/ -typedef struct vsound_exp_s -{ - // interface validator - size_t api_size; // must matched with sizeof(vsound_api_t) - size_t com_size; // must matched with sizeof(stdlib_api_t) - - qboolean (*Init)( void *hInst ); // init sound - void (*Shutdown)( void ); - - // sound manager - void (*BeginRegistration)( void ); - sound_t (*RegisterSound)( const char *name ); - void (*EndRegistration)( void ); - - void (*StartLocalSound)( const char *name ); // menus - void (*StartSound)( const vec3_t pos, int ent, int chan, sound_t sfx, float vol, float attn, int pitch, int flags ); - void (*StaticSound)( const vec3_t pos, int ent, int chan, sound_t sfx, float vol, float attn, int pitch, int flags ); - void (*StreamRawSamples)( int samples, int rate, int width, int channels, const byte *data ); - void (*FadeClientVolume)( float fadePercent, float fadeOutSeconds, float holdTime, float fadeInSeconds ); - int (*GetCurrentStaticSounds)( soundlist_t *pout, int size, int entchannel ); - void (*StartBackgroundTrack)( const char *introTrack, const char *loopTrack ); - void (*StopBackgroundTrack)( void ); - void (*PauseBackgroundTrack)( int pause ); - - void (*StartStreaming)( void ); - void (*StopStreaming)( void ); - - void (*RenderFrame)( struct ref_params_s *fd ); - void (*StopSound)( int entnum, int channel, const char *soundname ); - void (*StopAllSounds)( void ); - void (*ExtraUpdate)( void ); - - void (*Activate)( qboolean active, void *hInst ); - -} vsound_exp_t; - -typedef struct vsound_imp_s -{ - // interface validator - size_t api_size; // must matched with sizeof(vsound_imp_t) - - qboolean (*GetEntitySpatialization)( int entnum, vec3_t origin, vec3_t velocity ); - void (*AmbientLevels)( const vec3_t p, byte *pvolumes ); - struct cl_entity_s *(*GetClientEdict)( int index ); - long (*GetAudioChunk)( char *rawdata, long length ); // movie soundtrack update - wavdata_t *(*GetMovieInfo)( void ); // params for soundtrack - float (*GetServerTime)( void ); - qboolean (*IsInMenu)( void ); // returns true when client is in-menu - qboolean (*IsActive)( void ); // returns true when client is completely in-game -} vsound_imp_t; - -#endif//VSOUND_API_H \ No newline at end of file diff --git a/release.bat b/release.bat index 06bb707a..f680f7a3 100644 --- a/release.bat +++ b/release.bat @@ -26,12 +26,6 @@ if errorlevel 1 set BUILD_ERROR=1 %MSDEV% vid_gl/vid_gl.dsp %CONFIG%"vid_gl - Win32 Release" %build_target% if errorlevel 1 set BUILD_ERROR=1 -%MSDEV% snd_dx/snd_dx.dsp %CONFIG%"snd_dx - Win32 Release" %build_target% -if errorlevel 1 set BUILD_ERROR=1 - -%MSDEV% utils/utils.dsp %CONFIG%"utils - Win32 Release" %build_target% -if errorlevel 1 set BUILD_ERROR=1 - if "%BUILD_ERROR%"=="" goto build_ok echo ********************* @@ -57,8 +51,6 @@ if exist engine\engine.plg del /f /q engine\engine.plg if exist mainui\mainui.plg del /f /q mainui\mainui.plg if exist launch\launch.plg del /f /q launch\launch.plg if exist vid_gl\vid_gl.plg del /f /q vid_gl\vid_gl.plg -if exist snd_dx\snd_dx.plg del /f /q snd_dx\snd_dx.plg -if exist utils\utils.plg del /f /q utils\utils.plg echo echo Build succeeded! diff --git a/snd_dx/s_export.c b/snd_dx/s_export.c deleted file mode 100644 index c0879547..00000000 --- a/snd_dx/s_export.c +++ /dev/null @@ -1,61 +0,0 @@ -//======================================================================= -// Copyright XashXT Group 2007 © -// s_export.c - sound library main -//======================================================================= - -#include "sound.h" - -vsound_imp_t si; -stdlib_api_t com; - -// main DLL entry point -BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) -{ - return TRUE; -} - -vsound_exp_t EXPORT *CreateAPI( stdlib_api_t *input, vsound_imp_t *engfuncs ) -{ - static vsound_exp_t snd; - - com = *input; - - // Sys_LoadLibrary can create fake instance, to check - // api version and api size, but second argument will be 0 - // and always make exception, run simply check to avoid it - if( engfuncs ) si = *engfuncs; - - // generic functions - snd.api_size = sizeof( vsound_exp_t ); - snd.com_size = sizeof( stdlib_api_t ); - - snd.Init = S_Init; - snd.Shutdown = S_Shutdown; - - // sound manager - snd.BeginRegistration = S_BeginRegistration; - snd.RegisterSound = S_RegisterSound; - snd.EndRegistration = S_EndRegistration; - - snd.FadeClientVolume = S_FadeClientVolume; - snd.StartSound = S_StartSound; - snd.StaticSound = S_StaticSound; - snd.StreamRawSamples = S_StreamRawSamples; - snd.StartLocalSound = S_StartLocalSound; - snd.StartBackgroundTrack = S_StartBackgroundTrack; - snd.StopBackgroundTrack = S_StopBackgroundTrack; - snd.GetCurrentStaticSounds = S_GetCurrentStaticSounds; - snd.PauseBackgroundTrack = S_StreamSetPause; - - snd.StartStreaming = S_StartStreaming; - snd.StopStreaming = S_StopStreaming; - - snd.ExtraUpdate = S_ExtraUpdate; - snd.RenderFrame = S_RenderFrame; - snd.StopSound = S_StopSound; - snd.StopAllSounds = S_StopAllSounds; - - snd.Activate = S_Activate; - - return &snd; -} \ No newline at end of file diff --git a/snd_dx/snd_dx.dsp b/snd_dx/snd_dx.dsp deleted file mode 100644 index 7728ce33..00000000 --- a/snd_dx/snd_dx.dsp +++ /dev/null @@ -1,169 +0,0 @@ -# Microsoft Developer Studio Project File - Name="snd_dx" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=snd_dx - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "snd_dx.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "snd_dx.mak" CFG="snd_dx - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "snd_dx - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "snd_dx - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "snd_dx - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "..\temp\snd_dx\!release" -# PROP Intermediate_Dir "..\temp\snd_dx\!release" -# PROP Ignore_Export_Lib 1 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PLATFORM_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /O2 /I "./" /I "../public" /I "../common" /I "../pm_shared" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c -# SUBTRACT CPP /YX -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x419 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /opt:nowin98 -# ADD LINK32 winmm.lib /nologo /dll /pdb:none /machine:I386 /nodefaultlib:"libcmt.lib" /opt:nowin98 -# SUBTRACT LINK32 /profile -# Begin Custom Build -TargetDir=\Xash3D\src_main\temp\snd_dx\!release -InputPath=\Xash3D\src_main\temp\snd_dx\!release\snd_dx.dll -SOURCE="$(InputPath)" - -"D:\Xash3D\snd_dx.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - copy $(TargetDir)\snd_dx.dll "D:\Xash3D\snd_dx.dll" - -# End Custom Build - -!ELSEIF "$(CFG)" == "snd_dx - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "..\temp\snd_dx\!debug" -# PROP Intermediate_Dir "..\temp\snd_dx\!debug" -# PROP Ignore_Export_Lib 1 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PLATFORM_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /Gm /Gi /GX /ZI /Od /I "./" /I "../public" /I "../common" /I "../pm_shared" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /FD /GZ /c -# SUBTRACT CPP /YX -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x419 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 winmm.lib /nologo /dll /debug /machine:I386 /nodefaultlib:"libcmt.lib" /pdbtype:sept -# SUBTRACT LINK32 /incremental:no /nodefaultlib -# Begin Custom Build -TargetDir=\Xash3D\src_main\temp\snd_dx\!debug -InputPath=\Xash3D\src_main\temp\snd_dx\!debug\snd_dx.dll -SOURCE="$(InputPath)" - -"D:\Xash3D\snd_dx.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - copy $(TargetDir)\snd_dx.dll "D:\Xash3D\snd_dx.dll" - -# End Custom Build - -!ENDIF - -# Begin Target - -# Name "snd_dx - Win32 Release" -# Name "snd_dx - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\s_backend.c -# End Source File -# Begin Source File - -SOURCE=.\s_dsp.c -# End Source File -# Begin Source File - -SOURCE=.\s_export.c -# End Source File -# Begin Source File - -SOURCE=.\s_load.c -# End Source File -# Begin Source File - -SOURCE=.\s_main.c -# End Source File -# Begin Source File - -SOURCE=.\s_mix.c -# End Source File -# Begin Source File - -SOURCE=.\s_mouth.c -# End Source File -# Begin Source File - -SOURCE=.\s_stream.c -# End Source File -# Begin Source File - -SOURCE=.\s_utils.c -# End Source File -# Begin Source File - -SOURCE=.\s_vox.c -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=.\s_openal.h -# End Source File -# Begin Source File - -SOURCE=.\sound.h -# End Source File -# End Group -# End Target -# End Project diff --git a/utils/ripper/conv_doom.c b/utils/ripper/conv_doom.c deleted file mode 100644 index 1bdabd9b..00000000 --- a/utils/ripper/conv_doom.c +++ /dev/null @@ -1,702 +0,0 @@ -//======================================================================= -// Copyright XashXT Group 2008 © -// conv_doom.c - convert doom1\2 resources -//======================================================================= - -#include "ripper.h" -#include -#include - -// doom .mus files -#define MUSIDHEADER ((0x1A<<24)+('S'<<16)+('U'<<8)+'M') // little-endian "MUS " -#define MIDIDHEADER "MThd\000\000\000\006\000\001" -#define TRACKMAGIC1 "\000\377\003\035" -#define TRACKMAGIC2 "\000\377\057\000" -#define TRACKMAGIC3 "\000\377\002\026" -#define TRACKMAGIC4 "\000\377\131\002\000\000" -#define TRACKMAGIC5 "\000\377\121\003\011\243\032" -#define TRACKMAGIC6 "\000\377\057\000" - -#define MIDBUFFER 0x20000 -#define last(e) ((byte)(e & 0x80)) -#define event_type(e) ((byte)((e & 0x7F)>>4)) -#define channel(e) ((byte)(e & 0x0F)) -#define mid_write1 VFS_Write - -typedef struct -{ - int ident; - word ScoreLength; - word ScoreStart; - word channels; // count of primary channels - word SecChannels; // count of secondary channels - word InstrCnt; - word dummy; - word *instruments; -} mus_t; - -struct track_s -{ - dword current; - char vel; - long DeltaTime; - byte LastEvent; - char *data; // primary data -}; - -// doom spritemodel_qc -typedef struct angled_s -{ - char name[10]; // copy of skin name - - int width; // lumpwidth - int height; // lumpheight - int origin[2]; // monster origin - byte xmirrored; // swap left and right -} angled_t; - -struct angledframe_s -{ - angled_t frame[8]; // angled group or single frame - int bounds[2]; // group or frame maxsizes - byte angledframes; // count of angled frames max == 8 - byte normalframes; // count of anim frames max == 1 - byte mirrorframes; // animation mirror stored - - char membername[8]; // current model name, four characsters - char animation; // current animation number - qboolean in_progress; // current state - file_t *f; // skin script -} flat; - -static size_t mid_write2( vfile_t *file, const uint *ptr, size_t size ) -{ - uint i, rev = 0; - - for( i = 0; (size_t)i < size; i++ ) - rev = (rev << 8) + (((*ptr) >>(i*8)) & 0xFF) ; - - return VFS_Write( file, &rev, size ); -} - -static void Conv_WriteMIDheader( vfile_t *file, uint ntrks, uint division ) -{ - mid_write1( file, MIDIDHEADER, 10 ); - mid_write2( file, &ntrks, 2 ); - mid_write2( file, &division, 2 ); -} - -static void Conv_WriteTrack( vfile_t *file, int tracknum, struct track_s track[] ) -{ - uint size; - size_t quot, rem; - - // do we risk overflow here ? - size = (uint)track[tracknum].current + 4; - mid_write1( file, "MTrk", 4 ); - if( !tracknum ) size += 33; - - mid_write2( file, &size, 4 ); - if( !tracknum) mid_write1( file, TRACKMAGIC1 "written by Xash MusLib Ripper", 33 ); - quot = (size_t)(track[tracknum].current / 4096); - rem = (size_t)(track[tracknum].current - quot * 4096); - mid_write1( file, track[tracknum].data, 4096 * quot ); - mid_write1( file, ((const byte *)track[tracknum].data) + 4096 * quot, rem ); - mid_write1( file, TRACKMAGIC2, 4 ); -} - -static void Conv_WriteFirstTrack( vfile_t *file ) -{ - uint size = 43; - - mid_write1( file, "MTrk", 4); - mid_write2( file, &size, 4 ); - mid_write1( file, TRACKMAGIC3, 4 ); - mid_write1( file, "by XashXT Group 2008 ©", 22 ); - mid_write1( file, TRACKMAGIC4, 6 ); - mid_write1( file, TRACKMAGIC5, 7 ); - mid_write1( file, TRACKMAGIC6, 4 ); -} - -static qboolean Conv_ReadMusHeader( vfile_t *f, mus_t *hdr ) -{ - qboolean result = true; - - VFS_Read( f, &hdr->ident, 4 ); - if( hdr->ident != MUSIDHEADER ) - return false; - - VFS_Read(f, &(hdr->ScoreLength), sizeof(word)); - VFS_Read(f, &(hdr->ScoreStart), sizeof(word)); - VFS_Read(f, &(hdr->channels), sizeof(word)); - VFS_Read(f, &(hdr->SecChannels), sizeof(word)); - VFS_Read(f, &(hdr->InstrCnt), sizeof(word)); - VFS_Read(f, &(hdr->dummy), sizeof(word)); - hdr->instruments = (word *)Mem_Alloc( basepool, hdr->InstrCnt * sizeof(word)); - - if(VFS_Read( f, hdr->instruments, hdr->InstrCnt * sizeof(word)) != hdr->InstrCnt * sizeof(word)) - result = false; - Mem_Free( hdr->instruments ); - return result; -} - -static char Conv_GetChannel( signed char MUS2MIDchannel[] ) -{ - signed char old15 = MUS2MIDchannel[15], max = -1; - int i; - - MUS2MIDchannel[15] = -1; - - for( i = 0; i < 16; i++ ) - { - if( MUS2MIDchannel[i] > max ) - max = MUS2MIDchannel[i]; - } - MUS2MIDchannel[15] = old15; - return (max == 8 ? 10 : max + 1); -} - -static void Conv_FreeTracks( struct track_s track[] ) -{ - int i ; - - for( i = 0; i < 16; i++ ) - { - if( track[i].data ) Mem_Free( track[i].data ) ; - } -} - -static uint Conv_ReadTime( vfile_t *file ) -{ - register uint time = 0; - int newbyte; - - do - { - VFS_Read( file, &newbyte, 1 ); - if( newbyte != EOF ) time = (time << 7) + (newbyte & 0x7F); - } while((newbyte != EOF) && (newbyte & 0x80)); - return time ; -} - -static void Conv_WriteByte( char MIDItrack, char byte, struct track_s track[] ) -{ - uint pos; - - pos = track[MIDItrack].current; - if( pos < MIDBUFFER ) - { - // need to reallocte ? - track[MIDItrack].data[pos] = byte; - } - else - { - Conv_FreeTracks( track ); - Sys_Break( "not enough memory\n" ); - } - track[MIDItrack].current++; -} - -static void Conv_WriteVarLen( int tracknum, register uint value, struct track_s track[] ) -{ - register uint buffer; - - buffer = value & 0x7f; - while((value >>= 7)) - { - buffer<<= 8; - buffer |= 0x80; - buffer += (value & 0x7f); - } - while( 1 ) - { - Conv_WriteByte( tracknum, buffer, track ); - if( buffer & 0x80 ) buffer >>= 8; - else break; - } -} - -static qboolean Conv_Mus2Mid( const char *musicname, byte *buffer, int bufsize ) -{ - struct track_s track[16]; - word TrackCnt = 0; - word division = 90; - byte et, MUSchannel, MIDIchannel, MIDItrack, NewEvent; - uint i, DeltaTime, TotalTime = 0, n = 0; - char event, data, ouch = 0; - signed char MUS2MIDchannel[16]; - vfile_t *file_mid, *file_mus = VFS_Create( buffer, bufsize ); - file_t *f; - static mus_t MUSh; - byte MUS2MIDcontrol[15] = - { - 0, // program change - not a MIDI control change - 0x00, // bank select - 0x01, // modulation pot - 0x07, // volume - 0x0A, // pan pot - 0x0B, // expression pot - 0x5B, // reverb depth - 0x5D, // chorus depth - 0x40, // sustain pedal - 0x43, // soft pedal - 0x78, // all sounds off - 0x7B, // all notes off - 0x7E, // mono - 0x7F, // poly - 0x79 // reset all controllers - }, MIDIchan2track[16]; - - if(!Conv_ReadMusHeader( file_mus, &MUSh )) - { - VFS_Close( file_mus ); - MsgDev(D_ERROR, "Conv_Mus2Mid: can't read mus header\n" ); - return false; - } - - if( VFS_Seek( file_mus, MUSh.ScoreStart, SEEK_SET )) - { - VFS_Close( file_mus ); - MsgDev(D_ERROR,"Conv_Mus2Mid: can't seek scores\n" ); - return false; - } - - if( MUSh.channels > 15 ) - { - VFS_Close( file_mus ); - MsgDev(D_ERROR,"Conv_Mus2Mid: too many channels\n" ); - return false; - } - - for( i = 0; i < 16; i++ ) - { - MUS2MIDchannel[i] = -1; - track[i].current = 0; - track[i].vel = 64; - track[i].DeltaTime = 0; - track[i].LastEvent = 0; - track[i].data = NULL; - } - - VFS_Read( file_mus, &event, 1 ); - et = event_type( event ); - MUSchannel = channel( event ); - - while((et != 6) && !VFS_Eof( file_mus ) && (event != EOF)) - { - if( MUS2MIDchannel[MUSchannel] == -1 ) - { - MIDIchannel = MUS2MIDchannel[MUSchannel] = (MUSchannel == 15 ? 9:Conv_GetChannel(MUS2MIDchannel)); - MIDItrack = MIDIchan2track[MIDIchannel] = (byte)(TrackCnt++); - track[MIDItrack].data = (char *)Mem_Alloc( basepool, MIDBUFFER ); - } - else - { - MIDIchannel = MUS2MIDchannel[MUSchannel]; - MIDItrack = MIDIchan2track [MIDIchannel]; - } - Conv_WriteVarLen( MIDItrack, track[MIDItrack].DeltaTime, track ); - track[MIDItrack].DeltaTime = 0; - - switch( et ) - { - case 0: // release note - NewEvent = 0x90 | MIDIchannel; - if( NewEvent != track[MIDItrack].LastEvent ) - { - Conv_WriteByte( MIDItrack, NewEvent, track ); - track[MIDItrack].LastEvent = NewEvent; - } - else n++; - VFS_Read( file_mus, &data, 1 ); - Conv_WriteByte( MIDItrack, data, track ); - Conv_WriteByte( MIDItrack, 0, track ); - break; - case 1: - NewEvent = 0x90 | MIDIchannel; - if( NewEvent != track[MIDItrack].LastEvent ) - { - Conv_WriteByte( MIDItrack, NewEvent, track ); - track[MIDItrack].LastEvent = NewEvent; - } - else n++; - VFS_Read( file_mus, &data, 1 ); - Conv_WriteByte( MIDItrack, data & 0x7F, track ); - if( data & 0x80 ) VFS_Read( file_mus, &track[MIDItrack].vel, 1 ); - Conv_WriteByte( MIDItrack, track[MIDItrack].vel, track ); - break; - case 2: - NewEvent = 0xE0 | MIDIchannel; - if( NewEvent != track[MIDItrack].LastEvent ) - { - Conv_WriteByte( MIDItrack, NewEvent, track ); - track[MIDItrack].LastEvent = NewEvent; - } - else n++; - VFS_Read( file_mus, &data, 1 ); - Conv_WriteByte( MIDItrack, (data & 1) << 6, track ); - Conv_WriteByte( MIDItrack, data >> 1, track ); - break; - case 3: - NewEvent = 0xB0 | MIDIchannel; - if( NewEvent != track[MIDItrack].LastEvent ) - { - Conv_WriteByte( MIDItrack, NewEvent, track ); - track[MIDItrack].LastEvent = NewEvent; - } - else n++; - VFS_Read( file_mus, &data, 1 ); - Conv_WriteByte( MIDItrack, MUS2MIDcontrol[data], track ); - if( data == 12 ) Conv_WriteByte( MIDItrack, MUSh.channels + 1, track ); - else Conv_WriteByte( MIDItrack, 0, track ); - break; - case 4: - VFS_Read( file_mus, &data, 1 ); - if( data ) - { - NewEvent = 0xB0 | MIDIchannel; - if( NewEvent != track[MIDItrack].LastEvent ) - { - Conv_WriteByte( MIDItrack, NewEvent, track ); - track[MIDItrack].LastEvent = NewEvent; - } - else n++; - Conv_WriteByte( MIDItrack, MUS2MIDcontrol[data], track ); - } - else - { - NewEvent = 0xC0 | MIDIchannel; - if( NewEvent != track[MIDItrack].LastEvent ) - { - Conv_WriteByte( MIDItrack, NewEvent, track ); - track[MIDItrack].LastEvent = NewEvent; - } - else n++; - } - VFS_Read( file_mus, &data, 1 ); - Conv_WriteByte( MIDItrack, data, track ); - break; - case 5: - case 7: - Conv_FreeTracks( track ); - MsgDev( D_ERROR, "Conv_Mus2Mid: bad event\n" ); - return false; - default: - break; - } - - if(last( event )) - { - DeltaTime = Conv_ReadTime( file_mus ); - TotalTime += DeltaTime; - for( i = 0; i < (int)TrackCnt; i++ ) - track[i].DeltaTime += DeltaTime; - } - VFS_Read( file_mus, &event, 1 ); - if( event != EOF ) - { - et = event_type( event ); - MUSchannel = channel( event ); - } - else ouch = 1; - } - if( ouch ) MsgDev(D_WARN, "Conv_Mus2Mid: %s.mus - end of file probably corrupted\n", musicname ); - - f = FS_Open(va( "%s/%s.mid", gs_gamedir, musicname ), "wb" ); - file_mid = VFS_Open( f, "w" ); - - Conv_WriteMIDheader( file_mid, TrackCnt + 1, division ); - Conv_WriteFirstTrack( file_mid ); - - for( i = 0; i < (int)TrackCnt; i++ ) - Conv_WriteTrack( file_mid, i, track ); - Conv_FreeTracks( track ); - FS_Close( VFS_Close( file_mid )); - VFS_Close( file_mus ); - - return true; -} - -static void Skin_RoundDimensions( int *scaled_width, int *scaled_height ) -{ - int width, height; - - for( width = 1; width < *scaled_width; width <<= 1 ); - for( height = 1; height < *scaled_height; height <<= 1 ); - - *scaled_width = bound( 1, width, 512 ); - *scaled_height = bound( 1, height, 512 ); -} - -void Skin_WriteSequence( void ) -{ - int i; - - Skin_RoundDimensions( &flat.bounds[0], &flat.bounds[1] ); - - // time to dump frames :) - if( flat.angledframes == 8 ) - { - // angled group is full, dump it! - FS_Print( flat.f, "\n$angled\n{\n" ); - FS_Printf( flat.f, "\t// frame '%c'\n", flat.frame[0].name[4] ); - FS_Printf( flat.f, "\t$resample\t\t%d %d\n", flat.bounds[0], flat.bounds[1] ); - for( i = 0; i < 8; i++) - { - FS_Printf( flat.f,"\t$load\t\t%s.bmp", flat.frame[i].name ); - if( flat.frame[i].xmirrored ) FS_Print( flat.f," flip_x\n"); - else FS_Print( flat.f, "\n" ); - FS_Printf( flat.f,"\t$frame\t\t0 0 %d %d", flat.frame[i].width, flat.frame[i].height ); - FS_Printf( flat.f, " 0.1 %d %d\n", flat.frame[i].origin[0], flat.frame[i].origin[1] ); - } - FS_Print( flat.f, "}\n" ); - } - else if( flat.normalframes == 1 ) - { - // single frame stored - FS_Print( flat.f, "\n" ); - FS_Printf( flat.f, "// frame '%c'\n", flat.frame[0].name[4] ); - FS_Printf( flat.f,"$resample\t\t%d %d\n", flat.bounds[0], flat.bounds[1] ); - FS_Printf( flat.f,"$load\t\t%s.bmp\n", flat.frame[0].name ); - FS_Printf( flat.f,"$frame\t\t0 0 %d %d", flat.frame[0].width, flat.frame[0].height ); - FS_Printf( flat.f, " 0.1 %d %d\n", flat.frame[0].origin[0], flat.frame[0].origin[1]); - } - - // drop mirror frames too - if( flat.mirrorframes == 8 ) - { - // mirrored group is always flipped - FS_Print( flat.f, "\n$angled\n{\n" ); - FS_Printf( flat.f, "\t//frame '%c' (mirror '%c')\n", flat.frame[0].name[6], flat.frame[0].name[4] ); - FS_Printf( flat.f, "\t$resample\t\t%d %d\n", flat.bounds[0], flat.bounds[1] ); - for( i = 2; i > -1; i--) - { - FS_Printf( flat.f,"\t$load\t\t%s.bmp flip_x\n", flat.frame[i].name ); - FS_Printf( flat.f,"\t$frame\t\t0 0 %d %d", flat.frame[i].width, flat.frame[i].height ); - FS_Printf( flat.f, " 0.1 %d %d\n", flat.frame[i].origin[0], flat.frame[i].origin[1] ); - } - for( i = 7; i > 2; i--) - { - FS_Printf( flat.f,"\t$load\t\t%s.bmp flip_x\n", flat.frame[i].name ); - FS_Printf( flat.f,"\t$frame\t\t0 0 %d %d", flat.frame[i].width, flat.frame[i].height ); - FS_Printf( flat.f, " 0.1 %d %d\n", flat.frame[i].origin[0], flat.frame[i].origin[1] ); - } - FS_Print( flat.f, "}\n" ); - } - - flat.bounds[0] = flat.bounds[1] = 0; - Mem_Set( &flat.frame, 0, sizeof( flat.frame )); - flat.angledframes = flat.normalframes = flat.mirrorframes = 0; // clear all -} - -void Skin_FindSequence( const char *name, rgbdata_t *pic ) -{ - uint headlen; - char num, header[10]; - - // create header from flat name - com.strncpy( header, name, 10 ); - headlen = com.strlen( name ); - - if( flat.animation != header[4] ) - { - // write animation - Skin_WriteSequence(); - flat.animation = header[4]; - } - - if( flat.animation == header[4] ) - { - // update bounds - if( flat.bounds[0] < pic->width ) flat.bounds[0] = pic->width; - if( flat.bounds[1] < pic->height) flat.bounds[1] = pic->height; - - // continue collect frames - if( headlen == 6 ) - { - num = header[5] - '0'; - if(num == 0) flat.normalframes++; // animation frame - if(num == 8) num = 0; // merge - flat.angledframes++; // angleframe stored - com.strncpy( flat.frame[num].name, header, 9 ); - flat.frame[num].width = pic->width; - flat.frame[num].height = pic->height; - flat.frame[num].origin[0] = pic->width>>1; // center - flat.frame[num].origin[1] = pic->height; // floor - flat.frame[num].xmirrored = false; - } - else if( headlen == 8 ) - { - // normal image - num = header[5] - '0'; - if(num == 8) num = 0; // merge - com.strncpy( flat.frame[num].name, header, 9 ); - flat.frame[num].width = pic->width; - flat.frame[num].height = pic->height; - flat.frame[num].origin[0] = pic->width>>1; // center - flat.frame[num].origin[1] = pic->height; // floor - flat.frame[num].xmirrored = false; - flat.angledframes++; // frame stored - - if( header[4] != header[6] ) - { - // mirrored groups - flat.mirrorframes++; - return; - } - - // mirrored image - num = header[7] - '0'; // angle it's a direct acess to group - if(num == 8) num = 0; // merge - com.strncpy( flat.frame[num].name, header, 9 ); - flat.frame[num].width = pic->width; - flat.frame[num].height = pic->height; - flat.frame[num].origin[0] = pic->width>>1; // center - flat.frame[num].origin[1] = pic->height; // floor - flat.frame[num].xmirrored = true; // it's mirror frame - flat.angledframes++; // frame stored - } - else Sys_Break( "Skin_CreateScript: invalid name %s\n", name ); // this never happens - } -} - -void Skin_ProcessScript( const char *wad, const char *name ) -{ - if( flat.in_progress ) - { - // finish script - Skin_WriteSequence(); - FS_Close( flat.f ); - flat.in_progress = false; - } - if( !flat.in_progress ) - { - // start from scratch - com.strncpy( flat.membername, name, 5 ); - flat.f = FS_Open( va( "%s/%s/%s.qc", gs_gamedir, wad, flat.membername ), "w" ); - flat.in_progress = true; - flat.bounds[0] = flat.bounds[1] = 0; - - // write description - FS_Print( flat.f,"//=======================================================================\n"); - FS_Printf( flat.f,"//\t\t\tCopyright XashXT Group %s ©\n", timestamp( TIME_YEAR_ONLY )); - FS_Print( flat.f,"//\t\t\twritten by Xash Miptex Decompiler\n"); - FS_Print( flat.f,"//=======================================================================\n"); - - // write sprite header - FS_Printf( flat.f, "\n$spritename\t%s.spr\n", flat.membername ); - FS_Print( flat.f, "$type\t\tfacing_upright\n" ); // constant - FS_Print( flat.f, "$texture\t\talphatest\n"); - FS_Print( flat.f, "$noresample\n" ); // comment this command by taste - } -} - -// close sequence for unexpected concessions -void Skin_FinalizeScript( void ) -{ - if( !flat.in_progress ) return; - - // finish script - Skin_WriteSequence(); - FS_Close( flat.f ); - flat.in_progress = false; -} - -void Skin_CreateScript( const char *name, rgbdata_t *pic ) -{ - string skinname, wadname; - - FS_ExtractFilePath( name, wadname ); // wad name - FS_FileBase( name, skinname ); // skinname - - if(com.strnicmp( skinname, flat.membername, 4 )) - Skin_ProcessScript( wadname, skinname ); - - if( flat.in_progress ) - Skin_FindSequence( skinname, pic ); -} - -/* -============ -ConvSKN -============ -*/ -qboolean ConvSKN( const char *name, byte *buffer, size_t filesize, const char *ext ) -{ - rgbdata_t *pic = FS_LoadImage( va( "#%s.flt", name ), buffer, filesize ); - - if( pic ) - { - FS_SaveImage( va("%s/%s.%s", gs_gamedir, name, ext ), pic ); - Skin_CreateScript( name, pic ); - Msg( "%s.flat\n", name ); // echo to console - FS_FreeImage( pic ); - return true; - } - return false; -} - -/* -============ -ConvFLP -============ -*/ -qboolean ConvFLP( const char *name, byte *buffer, size_t filesize, const char *ext ) -{ - rgbdata_t *pic = FS_LoadImage( va( "#%s.flt", name ), buffer, filesize ); - - if( pic ) - { - FS_SaveImage(va("%s/%s.%s", gs_gamedir, name, ext ), pic ); - Msg( "%s.flat\n", name ); // echo to console - FS_FreeImage( pic ); - return true; - } - return false; -} - -/* -============ -ConvFLT -============ -*/ -qboolean ConvFLT( const char *name, byte *buffer, size_t filesize, const char *ext ) -{ - rgbdata_t *pic = FS_LoadImage( va( "#%s.flt", name ), buffer, filesize ); - - if( pic ) - { - string savedname, tempname, path; - - if( pic->flags & IMAGE_HAS_ALPHA ) - { - // insert '{' symbol for transparency textures - FS_ExtractFilePath( name, path ); - FS_FileBase( name, tempname ); - com.snprintf( savedname, MAX_STRING, "%s/{%s", path, tempname ); - } - else com.strncpy( savedname, name, MAX_STRING ); - - FS_SaveImage( va("%s/%s.%s", gs_gamedir, savedname, ext ), pic ); - Conv_CreateShader( savedname, pic, "flt", NULL, 0, 0 ); - Msg( "%s.flat\n", savedname ); // echo to console - FS_FreeImage( pic ); - return true; - } - return false; -} - -/* -============ -ConvMID -============ -*/ -qboolean ConvMID( const char *name, byte *buffer, size_t filesize, const char *ext ) -{ - if(Conv_Mus2Mid( name, buffer, filesize )) - { - Msg( "%s.mus\n", name ); // echo to console - return true; - } - return false; -} \ No newline at end of file diff --git a/utils/ripper/conv_image.c b/utils/ripper/conv_image.c deleted file mode 100644 index d3efc666..00000000 --- a/utils/ripper/conv_image.c +++ /dev/null @@ -1,165 +0,0 @@ -//======================================================================= -// Copyright XashXT Group 2008 © -// conv_image.c - convert various image type -//======================================================================= - -#include "ripper.h" - -/* -======================================================================== - -.WAL image format (Wally textures) - -======================================================================== -*/ -typedef struct wal_s -{ - char name[32]; - uint width, height; - uint offsets[4]; // four mip maps stored - char animname[32]; // next frame in animation chain - int flags; - int contents; - int value; -} wal_t; - -/* -============ -ConvWAL -============ -*/ -qboolean ConvWAL( const char *name, byte *buffer, size_t filesize, const char *ext ) -{ - rgbdata_t *pic = FS_LoadImage( va( "#%s.wal", name ), buffer, filesize ); - - if( pic ) - { - wal_t *wal = (wal_t *)buffer; - FS_SaveImage( va("%s/%s.%s", gs_gamedir, name, ext ), pic ); - Conv_CreateShader( name, pic, ext, wal->animname, wal->flags, wal->contents ); - Msg("%s.wal\n", name ); // echo to console - FS_FreeImage( pic ); - return true; - } - return false; -} - -/* -============= -ConvBMP -============= -*/ -qboolean ConvBMP( const char *name, byte *buffer, size_t filesize, const char *ext ) -{ - rgbdata_t *pic = FS_LoadImage( va( "#%s.bmp", name ), buffer, filesize ); - - if( pic ) - { - FS_SaveImage( va("%s/%s.%s", gs_gamedir, name, ext ), pic ); - Conv_CreateShader( name, pic, ext, NULL, 0, 0 ); - Msg( "%s.bmp\n", name, ext ); // echo to console - FS_FreeImage( pic ); - return true; - } - return false; -} - -/* -============= -ConvPCX - -this also uses by SP2_ConvertFrame -============= -*/ -qboolean ConvPCX( const char *name, byte *buffer, size_t filesize, const char *ext ) -{ - rgbdata_t *pic = FS_LoadImage( va( "#%s.pcx", name ), buffer, filesize ); - - if( pic ) - { - FS_SaveImage( va("%s/%s.%s", gs_gamedir, name, ext ), pic ); - // pcx images not required shader because it hud pics or sprite frames - Msg( "%s.pcx\n", name ); // echo to console - FS_FreeImage( pic ); - return true; - } - return false; -} - -/* -============= -ConvVTF -============= -*/ -qboolean ConvVTF( const char *name, byte *buffer, size_t filesize, const char *ext ) -{ - rgbdata_t *pic = FS_LoadImage( va( "#%s.vtf", name ), buffer, filesize ); - - if( pic ) - { - FS_SaveImage( va("%s/%s.%s", gs_gamedir, name, ext ), pic ); - Conv_CreateShader( name, pic, ext, NULL, 0, 0 ); - Msg( "%s.vtf\n", name ); // echo to console - FS_FreeImage( pic ); - return true; - } - return false; -} - -/* -============ -ConvMIP -============ -*/ -qboolean ConvMIP( const char *name, byte *buffer, size_t filesize, const char *ext ) -{ - rgbdata_t *pic = FS_LoadImage( va( "#%s.mip", name ), buffer, filesize ); - - if( pic ) - { - FS_SaveImage( va("%s/%s.%s", gs_gamedir, name, ext ), pic ); - Conv_CreateShader( name, pic, ext, NULL, 0, 0 ); - Msg( "%s.mip\n", name ); // echo to console - FS_FreeImage( pic ); - return true; - } - return false; -} - -/* -============ -ConvLMP -============ -*/ -qboolean ConvLMP( const char *name, byte *buffer, size_t filesize, const char *ext ) -{ - rgbdata_t *pic = FS_LoadImage( va( "#%s.lmp", name ), buffer, filesize ); - - if( pic ) - { - FS_SaveImage(va("%s/%s.%s", gs_gamedir, name, ext ), pic ); - Msg("%s.lmp\n", name ); // echo to console - FS_FreeImage( pic ); - return true; - } - return false; -} - -/* -============ -ConvFNT -============ -*/ -qboolean ConvFNT( const char *name, byte *buffer, size_t filesize, const char *ext ) -{ - rgbdata_t *pic = FS_LoadImage( va( "#%s.fnt", name ), buffer, filesize ); - - if( pic ) - { - FS_SaveImage(va("%s/%s.%s", gs_gamedir, name, ext ), pic ); - Msg("%s.fnt\n", name ); // echo to console - FS_FreeImage( pic ); - return true; - } - return false; -} \ No newline at end of file diff --git a/utils/ripper/conv_shader.c b/utils/ripper/conv_shader.c deleted file mode 100644 index 58b82273..00000000 --- a/utils/ripper/conv_shader.c +++ /dev/null @@ -1,545 +0,0 @@ -//======================================================================= -// Copyright XashXT Group 2007 © -// conv_shader.c - analyze and write texture shader -//======================================================================= - -#include "ripper.h" -#include "mathlib.h" -#include "utils.h" - -// q2 wal contents -#define Q2_CONTENTS_SOLID 0x00000001 // an eye is never valid in a solid -#define Q2_CONTENTS_WINDOW 0x00000002 // translucent, but not watery -#define Q2_CONTENTS_AUX 0x00000004 -#define Q2_CONTENTS_LAVA 0x00000008 -#define Q2_CONTENTS_SLIME 0x00000010 -#define Q2_CONTENTS_WATER 0x00000020 -#define Q2_CONTENTS_MIST 0x00000040 - -// remaining contents are non-visible, and don't eat brushes -#define Q2_CONTENTS_AREAPORTAL 0x00008000 -#define Q2_CONTENTS_PLAYERCLIP 0x00010000 -#define Q2_CONTENTS_MONSTERCLIP 0x00020000 -#define Q2_CONTENTS_CLIP (Q2_CONTENTS_PLAYERCLIP|Q2_CONTENTS_MONSTERCLIP) - -// currents can be added to any other contents, and may be mixed -#define Q2_CONTENTS_CURRENT_0 0x00040000 -#define Q2_CONTENTS_CURRENT_90 0x00080000 -#define Q2_CONTENTS_CURRENT_180 0x00100000 -#define Q2_CONTENTS_CURRENT_270 0x00200000 -#define Q2_CONTENTS_CURRENT_UP 0x00400000 -#define Q2_CONTENTS_CURRENT_DOWN 0x00800000 - -#define Q2_CONTENTS_ORIGIN 0x01000000 // removed before BSP'ing an entity - -#define Q2_CONTENTS_MONSTER 0x02000000 // should never be on a brush, only in game -#define Q2_CONTENTS_DEADMONSTER 0x04000000 -#define Q2_CONTENTS_DETAIL 0x08000000 // brushes to be added after vis leafs -#define Q2_CONTENTS_TRANSLUCENT 0x10000000 // auto set if any surface has trans -#define Q2_CONTENTS_LADDER 0x20000000 -#define Q2_CONTENTS_TRIGGER 0x40000000 // trigger - -#define SURF_LIGHT 0x00000001 // value will hold the light strength -#define SURF_SLICK 0x00000002 // effects game physics -#define SURF_SKY 0x00000004 // don't draw, but add to skybox -#define SURF_WARP 0x00000008 // turbulent water warp -#define SURF_TRANS33 0x00000010 // 33% opacity -#define SURF_TRANS66 0x00000020 // 66% opacity -#define SURF_FLOWING 0x00000040 // scroll towards angle -#define SURF_NODRAW 0x00000080 // don't bother referencing the texture -#define SURF_HINT 0x00000100 // make a primary bsp splitter -#define SURF_SKIP 0x00000200 // completely ignore, allowing non-closed brushes - -// xash 0.45 surfaces replacement table -#define SURF_MIRROR 0x00010000 // mirror surface -#define SURF_PORTAL 0x00020000 // portal surface -#define SURF_ALPHATEST 0x00040000 // alpha surface - -string animmap[256]; // should be enoguh -int animcount; // process counter -int num_anims; // shader total count -file_t *f; - -static float ColorNormalize( const vec3_t in, vec3_t out ) -{ - float max, scale; - - max = in[0]; - if( in[1] > max ) max = in[1]; - if( in[2] > max ) max = in[2]; - - if( max == 0 ) - { - out[0] = out[1] = out[2] = 1.0f; - return 0; - } - - scale = 1.0f / max; - VectorScale( in, scale, out ); - - return max; -} - -qboolean Conv_WriteShader( const char *shaderpath, const char *imagepath, rgbdata_t *p, float *rad, float scale, int flags, int contents ) -{ - file_t *f = NULL; - string qcname, qcpath; - string temp, lumpname; - string wadname, shadername; - int i, lightmap_stage = false; - - // write also wadlist.qc for xwad compiler - FS_ExtractFilePath( imagepath, temp ); - FS_FileBase( imagepath, lumpname ); - FS_FileBase( temp, qcname ); - FS_FileBase( temp, wadname ); - com.snprintf( shadername, MAX_STRING, "%s/%s", temp, lumpname ); - FS_DefaultExtension( qcname, ".qc" ); - FS_DefaultExtension( wadname, ".wad" ); // check for wad later - com.snprintf( qcpath, MAX_STRING, "%s/%s/$%s", gs_gamedir, temp, qcname ); - - if( write_qscsript ) - { - if(FS_FileExists( qcpath )) - { - script_t *test; - token_t token; - - // already exist, search for current name - test = Com_OpenScript( qcpath, NULL, 0 ); - while( Com_ReadToken( test, SC_ALLOW_NEWLINES|SC_PARSE_GENERIC, &token )) - { - if( !com.stricmp( token.string, "$mipmap" )) - { - Com_ReadToken( test, SC_PARSE_GENERIC, &token ); - if( !com.stricmp( token.string, lumpname )) - { - Com_CloseScript( test ); - goto check_shader; // already exist - } - } - Com_SkipRestOfLine( test ); - } - Com_CloseScript( test ); - f = FS_Open( qcpath, "a" ); // append - } - else - { - FS_StripExtension( qcname ); // no need anymore - f = FS_Open( qcpath, "w" ); // new file - // write description - FS_Print(f,"//=======================================================================\n"); - FS_Printf(f,"//\t\t\tCopyright XashXT Group %s ©\n", timestamp( TIME_YEAR_ONLY )); - FS_Print(f,"//\t\t\twritten by Xash Miptex Decompiler\n"); - FS_Print(f,"//=======================================================================\n"); - FS_Printf(f,"$wadname\t%s.wad\n\n", qcname ); - } - } - - if( f && p ) - { - FS_Printf( f,"$mipmap\t%s\t0 0 %d %d\n", lumpname, p->width, p->height ); - if( p->flags & IMAGE_HAS_LUMA ) // also add luma image if present - FS_Printf( f,"$mipmap\t%s_luma\t0 0 %d %d\n", lumpname, p->width, p->height ); - FS_Close( f ); // all done - } - -check_shader: - // invalid animation counter, kill it - if( num_anims == 1 ) animcount = num_anims = 0; - - // nothing to write - if( !flags && !contents && !num_anims && !(p->flags & IMAGE_HAS_LUMA)) - return false; - - if(FS_FileExists( shaderpath )) - { - script_t *test; - token_t token; - - // already exist, search for current shader - test = Com_OpenScript( shaderpath, NULL, 0 ); - while( Com_ReadToken( test, SC_ALLOW_NEWLINES|SC_ALLOW_PATHNAMES2, &token )) - { - if( !com.stricmp( token.string, shadername )) - { - Com_CloseScript( test ); - return false; // already exist - } - Com_SkipRestOfLine( test ); - } - Com_CloseScript( test ); - f = FS_Open( shaderpath, "a" ); // append - } - else - { - f = FS_Open( shaderpath, "w" ); // new file - // write description - FS_Print(f,"//=======================================================================\n"); - FS_Printf(f,"//\t\t\tCopyright XashXT Group %s ©\n", timestamp( TIME_YEAR_ONLY )); - FS_Print(f,"//\t\t\twritten by Xash Miptex Decompiler\n"); - FS_Print(f,"//=======================================================================\n"); - } - - FS_Printf( f, "\n%s\n{\n", shadername ); // write shadername - - if( contents & Q2_CONTENTS_CLIP && contents && Q2_CONTENTS_PLAYERCLIP ) - FS_Print( f, "\tsurfaceparm\tclip\n" ); - else if( contents & Q2_CONTENTS_MONSTERCLIP ) FS_Print( f, "\tsurfaceparm\tmonsterclip\n" ); - else if( contents & Q2_CONTENTS_PLAYERCLIP ) FS_Print( f, "\tsurfaceparm\tplayerclip\n" ); - else if( contents & Q2_CONTENTS_WINDOW ) FS_Print( f, "\tsurfaceparm\twindow\n" ); - else if( contents & Q2_CONTENTS_ORIGIN ) FS_Print( f, "\tsurfaceparm\torigin\n" ); - else if( contents & Q2_CONTENTS_TRANSLUCENT ) FS_Print( f, "\tsurfaceparm\ttrans\n" ); - else if( contents & Q2_CONTENTS_AREAPORTAL ) FS_Print( f, "\tsurfaceparm\tareaportal\n" ); - else if( contents & Q2_CONTENTS_TRIGGER ) FS_Print( f, "\tsurfaceparm\ttrigger\n" ); - else if( contents & Q2_CONTENTS_DETAIL ) FS_Print( f, "\tsurfaceparm\tdetail\n" ); - - if( flags & SURF_LIGHT ) - { - if(!VectorIsNull( rad )) FS_Printf(f, "\tq3map_lightRGB\t%g %g %g\n", rad[0], rad[1], rad[2] ); - if( scale ) FS_Printf(f, "\tq3map_surfacelight\t%.f\n", scale ); - if( !num_anims ) - { - FS_Printf( f, "\t{\n\t\tmap\t%s\n\t}\n", shadername ); - lightmap_stage = true; - } - } - - if( flags & SURF_WARP ) - { - FS_Print( f, "\tq3map_globaltexture\n" ); - FS_Print( f, "\tsurfaceparm\tnoLightMap\n" ); - FS_Print( f, "\ttessSize\t\t64\n\n" ); - - // server relevant contents - if(contents & Q2_CONTENTS_WATER) - FS_Print( f, "\tsurfaceparm\twater\n" ); - else if(contents & Q2_CONTENTS_SLIME) - FS_Print( f, "\tsurfaceparm\tslime\n" ); - else if(contents & Q2_CONTENTS_LAVA) - FS_Print( f, "\tsurfaceparm\tlava\n" ); - else FS_Print( f, "\tsurfaceparm\twater\n" ); - - FS_Printf( f, "\t{\n\t\tmap\t%s\n", shadername ); // save basemap - if( flags & (SURF_TRANS33|SURF_TRANS66)) - { - FS_Print( f, "\t\tblendFunc\tGL_SRC_ALPHA\tGL_ONE_MINUS_SRC_ALPHA\n" ); - FS_Print( f, "\t\tAlphaGen\t\tvertex\n" ); - } - FS_Print( f, "\t\ttcGen\twarp\n\t}\n" ); // warp - lightmap_stage = false; - } - else if( flags & SURF_SKY ) FS_Print( f, "\tsurfaceparm\tsky\n" ); - else if( flags & SURF_HINT ) FS_Print( f, "\tsurfaceparm\thint\n" ); - else if( flags & SURF_SKIP ) FS_Print( f, "\tsurfaceparm\tskip\n" ); - else if( flags & (SURF_TRANS33|SURF_TRANS66)) - { - FS_Printf( f, "\t{\n\t\tmap\t%s\n\n", shadername ); // save basemap - FS_Print( f, "\t\tblendFunc\tGL_SRC_ALPHA\tGL_ONE_MINUS_SRC_ALPHA\n" ); - FS_Print( f, "\t\tAlphaGen\t\tentity\n\t}\n" ); - lightmap_stage = true; - } - else if( flags & SURF_ALPHATEST ) - { - FS_Printf( f, "\t{\n\t\tmap\t%s\n\n", shadername ); // save basemap - FS_Print( f, "\t\talphaFunc\tGL_GREATER 0.666f\t// id Software magic value\n" ); - FS_Print( f, "\t\tAlphaGen\tidentity\n\t}\n" ); - lightmap_stage = true; - } - else if( flags & SURF_NODRAW ) FS_Print( f, "\tsurfaceparm\tnodraw\n" ); - - if( num_anims ) - { - FS_Printf( f, "\t{\n\t\tAnimFrequency\t%i\n", animcount ); // #frames per second - for( i = 0; i < num_anims; i++ ) - FS_Printf( f, "\t\tmap\t\t%s\n", animmap[i] ); - FS_Printf( f, "\t}\n" ); // close section - lightmap_stage = true; - } - else if( p->flags & IMAGE_HAS_LUMA && !( flags & SURF_WARP )) - { - FS_Printf( f, "\t{\n\t\tmap\t%s\n\t}\n", shadername ); - lightmap_stage = true; - } - - if( lightmap_stage ) - { - FS_Print( f, "\t{\n\t\tmap\t$lightmap\n" ); // lightmap stage - FS_Print( f, "\t\tblendFunc\tfilter\n" ); - FS_Print( f, "\t}\n" ); - } - - if( p->flags & IMAGE_HAS_LUMA ) - { - if( num_anims ) - { - FS_Printf( f, "\t{\n\t\tAnimFrequency\t%i\n", animcount ); // #frames per second - for( i = 0; i < num_anims; i++ ) - FS_Printf( f, "\t\tmap\t\t%s_luma\n", animmap[i] ); // anim luma stage - FS_Printf( f, "\t\tblendFunc\t\tadd\n" ); - FS_Printf( f, "\t}\n" ); // close section - animcount = num_anims = 0; // done - } - else - { - FS_Printf( f, "\t{\n\t\tmap\t%s_luma\n", shadername ); // save luma - FS_Printf( f, "\t\tblendFunc\tadd\n" ); - if( flags & SURF_WARP ) FS_Print( f, "\t\ttcGen\twarp\n" ); - FS_Printf( f, "\t}\n" ); // close section - } - } - - FS_Print( f, "}\n" ); // close shader - FS_Close( f ); - - return true; -} - -/* -============= -generic flags extractor -============= -*/ -void Conv_ShaderGetFlags( const char *imagename, const char *shadername, const char *ext, int *flags, int *contents, const char *anim ) -{ - if( game_family == GAME_DOOM1 ) - { - num_anims = animcount = 0; // valid onlt for current frame so reset it - - if( !com.strnicmp( imagename, "sky", 3 )) *flags |= SURF_SKY; - if( com.stristr( imagename, "lit" )) *flags |= SURF_LIGHT; - - if( !com.strnicmp( "sw", imagename, 2 ) || !com.strnicmp( "{sw", imagename, 3 )) - { - // wallbuttons anim support - string temp1; - char c1; - int i, j; - - if( imagename[0] == '{' && imagename[4] == '_' ) - c1 = imagename[5], j = 5; - else if( imagename[3] == 's' ) - c1 = imagename[4], j = 4; - else if( imagename[4] == '_' ) - c1 = imagename[5], j = 5; - - if( c1 >= '0' && c1 <= '9' ); - else return; - - com.strncpy( temp1, imagename, MAX_STRING ); - for( i = 0; i < 10; i++ ) // Doom1 anim: 0 - 9 - { - if( !FS_FileExists( va( "%s/%s.flt", shadername, temp1 ))) break; - com.snprintf( animmap[animcount++], MAX_STRING, "%s/%s", shadername, temp1 ); - temp1[j]++; // increase symbol - } - num_anims = animcount; // can be dump now - } - } - else if( game_family == GAME_QUAKE1 || game_family == GAME_HALFLIFE ) - { - num_anims = animcount = 0; // valid onlt for current frame so reset it - - if( com.stristr( imagename, "water" )) - { - *contents |= Q2_CONTENTS_WATER; - *flags |= SURF_WARP; // liquids - } - else if( com.stristr( imagename, "slime" )) - { - *contents |= Q2_CONTENTS_SLIME; - *flags |= SURF_WARP; // liquids - } - else if( com.stristr( imagename, "lava" )) - { - *contents |= Q2_CONTENTS_LAVA; - *flags |= SURF_WARP; // liquids - } - - // search for keywords - if( !com.strnicmp( imagename, "sky", 3 )) *flags |= SURF_SKY; - else if( !com.strnicmp( imagename, "origin",6)) *contents |= Q2_CONTENTS_ORIGIN; - else if( !com.strnicmp( imagename, "clip", 4 )) *contents |= Q2_CONTENTS_CLIP; - else if( !com.strnicmp( imagename, "hint", 4 )) *flags |= SURF_HINT; - else if( !com.strnicmp( imagename, "skip", 4 )) *flags |= SURF_SKIP; - else if( !com.strnicmp( imagename, "null", 4 )) *flags |= SURF_NODRAW; - else if( !com.strnicmp( imagename, "translucent", 11 )) *contents |= Q2_CONTENTS_TRANSLUCENT; - else if( !com.strnicmp( imagename, "glass", 5 )) *flags |= SURF_TRANS66; - else if( !com.strnicmp( imagename, "mirror", 6 )) *flags |= SURF_MIRROR; - else if( !com.strnicmp( imagename, "portal", 6 )) *flags |= SURF_PORTAL; - else if( com.stristr( imagename, "trigger" )) *contents |= Q2_CONTENTS_TRIGGER; - else if( com.stristr( imagename, "lite" )) *flags |= SURF_LIGHT; - - // try to exctract contents and flags directly form mip-name - if( imagename[0] == '!' || imagename[0] == '*' ) *flags |= SURF_WARP; // liquids - else if( imagename[0] == '{' ) - { - *flags |= SURF_ALPHATEST; // grates - *contents |= Q2_CONTENTS_TRANSLUCENT; - } - else if( imagename[0] == '~' ) *flags |= SURF_LIGHT; // light definition - else if( imagename[0] == '+' ) - { - char c1 = imagename[1]; - string temp1; - int i; - - // HL: first map is off second map is on - if( c1 != '0' && c1 != 'a' && c1 != 'A' ) - { - return; - } - com.strncpy( temp1, imagename, MAX_STRING ); - for( i = 0; i < 10; i++ ) // Quake anim: 0 - 9 - { - if( !MipExist( va("%s/%s.mip", shadername, temp1 ))) break; - com.snprintf( animmap[animcount++], MAX_STRING, "%s/%s", shadername, temp1 ); - temp1[1]++; // increase symbol - } - if( i > 1 ) - { - num_anims = animcount; // can be dump now - return; - } - - if( c1 == 'a' || c1 == 'A' ) temp1[1] = '0'; - else if( c1 == '0' ) temp1[1] = 'A'; - - for( i = 0; i < 10; i++ ) // Quake anim A - K - { - if( !MipExist( va("%s/%s.mip", shadername, temp1 ))) break; - com.snprintf( animmap[animcount++], MAX_STRING, "%s/%s", shadername, temp1 ); - temp1[1]++; // increase symbol - } - num_anims = animcount; // can be dump now - } - } - else if( game_family == GAME_QUAKE2 ) - { -/* - // this code it's totally wrong, disabled for now - if( animcount && !com.strlen( anim )) - { - // end of chain, dump now - num_anims = animcount; - return; - } - - if( anim && com.strlen( anim )) - { - int i; - - if( animcount == 0 ) // add himself first - com.snprintf( animmap[animcount++], MAX_STRING, "%s/%s", shadername, imagename ); - - for( i = 0; i < animcount; i++ ) - { - if( !com.stricmp( animmap[i], anim )) - { - // chain is looped, dump now - num_anims = animcount; - return; - } - } - - // add next frame - if( animcount == i ) com.strncpy( animmap[animcount++], anim, MAX_STRING ); - } - // UNDONE: remove some flags -*/ - } -} - -qboolean Conv_CreateShader( const char *name, rgbdata_t *pic, const char *ext, const char *anim, int surf, int cnt ) -{ - string shadername, imagename; - string shaderpath, imagepath; - vec3_t radiocity = {0,0,0}; - float intencity = 0; - int flags = 0, contents = 0; - - // extract fodler name from path - FS_ExtractFilePath( name, shadername ); - FS_FileBase( shadername, shadername ); // remove "textures" from path - FS_FileBase( name, imagename ); - com.snprintf( shaderpath, MAX_STRING, "%s/scripts/%s.shader", gs_gamedir, shadername ); - com.strncpy( imagepath, name, MAX_STRING ); // full path - - flags |= surf; // .wal can transmit flags here - contents |= cnt; - - Conv_ShaderGetFlags( imagename, shadername, ext, &flags, &contents, anim ); - if( animcount >= 256 ) Sys_Break( "Conv_CreateShader: too many animations in shader\n" ); - - if( pic->flags & IMAGE_HAS_LUMA ) - { - // write luma image silently - Image_Process( &pic, 0, 0, IMAGE_MAKE_LUMA ); - FS_SaveImage( va("%s/%s_luma.%s", gs_gamedir, name, ext ), pic ); - } - if( flags & SURF_LIGHT ) - { - int j, texels; - byte *pal, *fin; - float scale; - - texels = pic->width * pic->height; - fin = pic->buffer; - pal = pic->palette; - - switch( pic->type ) - { - case PF_RGBA_32: - for( j = 0; j < texels; j++, fin += 4 ) - { - radiocity[0] += fin[0]; - radiocity[1] += fin[1]; - radiocity[2] += fin[2]; - } - texels *= 4; - break; - case PF_BGRA_32: - case PF_ABGR_64: - for( j = 0; j < texels; j++, fin += 4 ) - { - radiocity[0] += fin[2]; - radiocity[1] += fin[1]; - radiocity[2] += fin[0]; - } - texels *= 4; - break; - case PF_RGB_24: - for( j = 0; j < texels; j++, fin += 3 ) - { - radiocity[0] += fin[0]; - radiocity[1] += fin[1]; - radiocity[2] += fin[2]; - } - texels *= 3; - break; - case PF_INDEXED_24: - case PF_INDEXED_32: - for( j = 0; j < texels; j++ ) - { - radiocity[0] += pal[fin[j]+0]; - radiocity[1] += pal[fin[j]+1]; - radiocity[2] += pal[fin[j]+2]; - } - break; - default: - MsgDev( D_WARN, "Conv_CreateShader: %s can't calculate reflectivity\n", name ); - return Conv_WriteShader( shaderpath, imagepath, pic, vec3_origin, 0.0f, flags, contents ); - } - - for( j = 0; j < 3; j++ ) - radiocity[j] /= texels; - scale = ColorNormalize( radiocity, radiocity ); - if( scale < 0.5f ) - { - scale *= 2.0f; - VectorScale( radiocity, scale, radiocity ); - } - intencity = texels * 255.0 / scale; // basic intensity value - } - return Conv_WriteShader( shaderpath, imagepath, pic, radiocity, intencity, flags, contents ); -} \ No newline at end of file diff --git a/utils/utils.dsp b/utils/utils.dsp deleted file mode 100644 index c44104d8..00000000 --- a/utils/utils.dsp +++ /dev/null @@ -1,185 +0,0 @@ -# Microsoft Developer Studio Project File - Name="utils" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=utils - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "utils.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "utils.mak" CFG="utils - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "utils - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "utils - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "utils - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "..\temp\utils\!release" -# PROP Intermediate_Dir "..\temp\utils\!release" -# PROP Ignore_Export_Lib 1 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PLATFORM_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /O2 /I "./" /I "../public" /I "bsplib" /I "ripper" /I "../common" /I "../engine" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c -# SUBTRACT CPP /YX -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x419 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /opt:nowin98 -# ADD LINK32 msvcrt.lib /nologo /dll /pdb:none /machine:I386 /nodefaultlib:"libc.lib" /opt:nowin98 -# SUBTRACT LINK32 /profile -# Begin Custom Build -TargetDir=\Xash3D\src_main\temp\utils\!release -InputPath=\Xash3D\src_main\temp\utils\!release\utils.dll -SOURCE="$(InputPath)" - -"D:\Xash3D\utils.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - copy $(TargetDir)\utils.dll "D:\Xash3D\utils.dll" - -# End Custom Build - -!ELSEIF "$(CFG)" == "utils - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "..\temp\utils\!debug" -# PROP Intermediate_Dir "..\temp\utils\!debug" -# PROP Ignore_Export_Lib 1 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PLATFORM_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /Gm /Gi /GX /ZI /Od /I "./" /I "../public" /I "bsplib" /I "ripper" /I "../common" /I "../engine" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /FD /GZ /c -# SUBTRACT CPP /YX -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x419 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 msvcrtd.lib user32.lib /nologo /dll /debug /machine:I386 /nodefaultlib:"libc.lib" /pdbtype:sept -# SUBTRACT LINK32 /incremental:no /nodefaultlib -# Begin Custom Build -TargetDir=\Xash3D\src_main\temp\utils\!debug -InputPath=\Xash3D\src_main\temp\utils\!debug\utils.dll -SOURCE="$(InputPath)" - -"D:\Xash3D\utils.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - copy $(TargetDir)\utils.dll "D:\Xash3D\utils.dll" - -# End Custom Build - -!ENDIF - -# Begin Target - -# Name "utils - Win32 Release" -# Name "utils - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\bsplib.c -# End Source File -# Begin Source File - -SOURCE=.\ripper\conv_bsplumps.c -# End Source File -# Begin Source File - -SOURCE=.\ripper\conv_doom.c -# End Source File -# Begin Source File - -SOURCE=.\ripper\conv_image.c -# End Source File -# Begin Source File - -SOURCE=.\ripper\conv_main.c -# End Source File -# Begin Source File - -SOURCE=.\ripper\conv_shader.c -# End Source File -# Begin Source File - -SOURCE=.\ripper\conv_sprite.c -# End Source File -# Begin Source File - -SOURCE=.\spritegen.c -# End Source File -# Begin Source File - -SOURCE=.\studio.c -# End Source File -# Begin Source File - -SOURCE=.\studio_utils.c -# End Source File -# Begin Source File - -SOURCE=.\wadlib.c -# End Source File -# Begin Source File - -SOURCE=.\ximage.c -# End Source File -# Begin Source File - -SOURCE=.\utils.c -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=.\mdllib.h -# End Source File -# Begin Source File - -SOURCE=.\ripper\ripper.h -# End Source File -# Begin Source File - -SOURCE=.\utils.h -# End Source File -# End Group -# End Target -# End Project diff --git a/utils/vgui/include/VGUI.h b/utils/vgui/include/VGUI.h new file mode 100644 index 00000000..acbd542e --- /dev/null +++ b/utils/vgui/include/VGUI.h @@ -0,0 +1,107 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_H +#define VGUI_H + +//If you are going to add stuff to the vgui core... +// +//Keep it simple. +// +//Never put code in a header. +// +//The name of the class is the name of the the file +// +//Each class gets its own .cpp file for its definition and a .h for its header. Helper +//classes can be used but only within the .cpp and not referenceable from anywhere else. +// +//Don't add unneeded files. Keep the API clean. +// +//No platform specific code in vgui\lib-src\vgui dir. Code in vgui\lib-src\vgui should +//only include from vgui\include or standard C includes. ie, if I see windows.h included +//anywhere but vgui\lib-src\win32 I will hunt you down and kill you. Don't give me any crap +//that mfc is platform inspecific. +// +//Always use <> and not "" for includes +// +//Use minimum dependencies in headers. Don't include another header if you can get away +//with forward declaring (which is usually the case) +// +//No macros in headers. They are tools of satan. This also means no use of DEFINEs, use enum +// +//Minimize global functions +// +//No global variables. +// +//Panel is getting pretty plump, try and avoid adding junk to it if you can + +//TODO: Look and Feel support +// add Panel::setPaintProxy, if _paintProxy exists, it calls _paintProxy->paint +// instead of Panel::paint. Components should implement their painting in a seperate +// plugin class. Perhaps to encourage this, Panel::paint should just go away completely +// The other option is to have Panel have the interface Paintable +// class Paintable +// { +// public: +// virtual void paint()=0; +// }; +// Then a component can implement its paint in the class itself and then call +// setPaintProxy(this). If this is the case _paintProxy->paint should always be called +// and never Panel::paint from within paintTraverse +//TODO: Figure out the 'Valve' Look and Feel and implement that instead of a the Java one +//TODO: Determine ownership policy for Borders, Layouts, etc.. +//TODO: tooltips support +//TODO: ComboKey (hot key support) +//TODO: add Background.cpp, remove paintBackground from all components +// Panel implements setBackground, Panel::paintBackground calls _background->paintBackground +// similiar to the way Border works. +//TODO: Builtin components should never overide paintBackground, only paint +//TODO: All protected members should be converted to private +//TODO: All member variables should be moved to the top of the class prototype +//TODO: All private methods should be prepended with private +//TODO: Use of word internal in method names is not consistent and confusing +//TODO: Cleanup so bullshit publics are properly named, maybe even figure out +// a naming convention for them +//TODO: Breakup InputSignal into logical pieces +//TODO: Button is in a state of disarray, it should have ButtonModel support +//TODO: get rid of all the stupid strdup laziness, convert to vgui_strdup +//TODO: actually figure out policy on String and implement it consistently +//TODO: implement createLayoutInfo for other Layouts than need it +//TODO: BorderLayout should have option for a null LayoutInfo defaulting to center +//TODO: SurfaceBase should go away, put it in Surface +//TODO: ActionSignals and other Signals should just set a flag when they fire. +// then App can come along later and fire all the signals +//TODO: Change all method naming to starting with a capital letter. + +#ifdef _WIN32 +# define VGUIAPI __declspec( dllexport ) +#else +# define VGUIAPI +#endif + +#define null 0L + +typedef unsigned char uchar; +typedef unsigned short ushort; +typedef unsigned int uint; +typedef unsigned long ulong; + +namespace vgui +{ + +VGUIAPI void vgui_setMalloc(void* (*malloc)(size_t size)); +VGUIAPI void vgui_setFree(void (*free)(void* memblock)); +VGUIAPI void vgui_strcpy(char* dst,int dstLen,const char* src); +VGUIAPI char* vgui_strdup(const char* src); +VGUIAPI int vgui_printf(const char* format,...); +VGUIAPI int vgui_dprintf(const char* format,...); +VGUIAPI int vgui_dprintf2(const char* format,...); + +} + +#endif + diff --git a/utils/vgui/include/VGUI_ActionSignal.h b/utils/vgui/include/VGUI_ActionSignal.h new file mode 100644 index 00000000..530f4685 --- /dev/null +++ b/utils/vgui/include/VGUI_ActionSignal.h @@ -0,0 +1,84 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_ACTIONSIGNAL_H +#define VGUI_ACTIONSIGNAL_H + +#include + +/* + +TODO: maybe try something like this.. + +class VGUIAPI ActionSignal +{ +}; + +class VGUIAPI ActionSignalSimple : public ActionSignal +{ +public: + virtual void actionPerformed(Panel* panel)=0; +}; + +class VGUIAPI ActionSignalInt : public ActionSignal +{ +public: + virtual void actionPerformed(int value,Panel* panel)=0; +}; + + +DefaultButtonModel would implement: + +virtual void addActionSignal(ActionSignal* s) +{ + if(s!=null) + { + _actionSignalDar.putElement(s); + } +} + +virtual void fireActionSignal() +{ + for(int i=0;i<_actionSignalDar.getCount();i++) + { + ActionSignal* signal=_actionSignalDar[i]; + + ActionSignalSimple* ss=dynamic_cast(signal); + if(ss!=null) + { + ss->actionPerformed(this); + } + + ActionSignalCommand* si=dynamic_cast(signal); + if(si!=null) + { + si->actionPerformed(_intValue,this); + } + } +} + + +*/ + +#include + +namespace vgui +{ + +class Panel; + +class VGUIAPI ActionSignal +{ +public: + virtual void actionPerformed(Panel* panel)=0; +}; + +} + +#endif + + diff --git a/utils/vgui/include/VGUI_App.h b/utils/vgui/include/VGUI_App.h new file mode 100644 index 00000000..a13cdb57 --- /dev/null +++ b/utils/vgui/include/VGUI_App.h @@ -0,0 +1,132 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_APP_H +#define VGUI_APP_H + +#include +#include +#include +#include +#include + +namespace vgui +{ + +enum MouseCode; +enum KeyCode; +class Panel; +class TickSignal; +class Scheme; +class TickSignal; +class SurfaceBase; + +class VGUIAPI App +{ +public: + App(); + App(bool externalMain); +public: + static App* getInstance(); + //TODO: the public and public bullshit are all messed up, need to organize + //TODO: actually all of the access needs to be properly thought out while you are at it +public: + virtual void start(); + virtual void stop(); + virtual void externalTick(); + virtual bool wasMousePressed(MouseCode code,Panel* panel); + virtual bool wasMouseDoublePressed(MouseCode code,Panel* panel); + virtual bool isMouseDown(MouseCode code,Panel* panel); + virtual bool wasMouseReleased(MouseCode code,Panel* panel); + virtual bool wasKeyPressed(KeyCode code,Panel* panel); + virtual bool isKeyDown(KeyCode code,Panel* panel); + virtual bool wasKeyTyped(KeyCode code,Panel* panel); + virtual bool wasKeyReleased(KeyCode code,Panel* panel); + virtual void addTickSignal(TickSignal* s); + virtual void setCursorPos(int x,int y); + virtual void getCursorPos(int& x,int& y); + virtual void setMouseCapture(Panel* panel); + virtual void setMouseArena(int x0,int y0,int x1,int y1,bool enabled); + virtual void setMouseArena(Panel* panel); + virtual void requestFocus(Panel* panel); + virtual Panel* getFocus(); + virtual void repaintAll(); + virtual void setScheme(Scheme* scheme); + virtual Scheme* getScheme(); + virtual void enableBuildMode(); + virtual long getTimeMillis(); + virtual char getKeyCodeChar(KeyCode code,bool shifted); + virtual void getKeyCodeText(KeyCode code,char* buf,int buflen); + virtual int getClipboardTextCount(); + virtual void setClipboardText(const char* text,int textLen); + virtual int getClipboardText(int offset,char* buf,int bufLen); + virtual void reset(); + virtual void internalSetMouseArena(int x0,int y0,int x1,int y1,bool enabled); + virtual bool setRegistryString(const char* key,const char* value); + virtual bool getRegistryString(const char* key,char* value,int valueLen); + virtual bool setRegistryInteger(const char* key,int value); + virtual bool getRegistryInteger(const char* key,int& value); + virtual void setCursorOveride(Cursor* cursor); + virtual Cursor* getCursorOveride(); + virtual void setMinimumTickMillisInterval(int interval); +public: //bullshit public stuff + virtual void main(int argc,char* argv[])=0; + virtual void run(); + virtual void internalCursorMoved(int x,int y,SurfaceBase* surfaceBase); //expects input in surface space + virtual void internalMousePressed(MouseCode code,SurfaceBase* surfaceBase); + virtual void internalMouseDoublePressed(MouseCode code,SurfaceBase* surfaceBase); + virtual void internalMouseReleased(MouseCode code,SurfaceBase* surfaceBase); + virtual void internalMouseWheeled(int delta,SurfaceBase* surfaceBase); + virtual void internalKeyPressed(KeyCode code,SurfaceBase* surfaceBase); + virtual void internalKeyTyped(KeyCode code,SurfaceBase* surfaceBase); + virtual void internalKeyReleased(KeyCode code,SurfaceBase* surfaceBase); +private: + virtual void init(); + virtual void updateMouseFocus(int x,int y,SurfaceBase* surfaceBase); + virtual void setMouseFocus(Panel* newMouseFocus); +protected: + virtual void surfaceBaseCreated(SurfaceBase* surfaceBase); + virtual void surfaceBaseDeleted(SurfaceBase* surfaceBase); + virtual void platTick(); + virtual void internalTick(); +protected: + static App* _instance; +protected: + bool _running; + bool _externalMain; + Dar _surfaceBaseDar; + Panel* _keyFocus; + Panel* _oldMouseFocus; + Panel* _mouseFocus; + Panel* _mouseCapture; + Panel* _wantedKeyFocus; + bool _mousePressed[MOUSE_LAST]; + bool _mouseDoublePressed[MOUSE_LAST]; + bool _mouseDown[MOUSE_LAST]; + bool _mouseReleased[MOUSE_LAST]; + bool _keyPressed[KEY_LAST]; + bool _keyTyped[KEY_LAST]; + bool _keyDown[KEY_LAST]; + bool _keyReleased[KEY_LAST]; + Dar _tickSignalDar; + Scheme* _scheme; + bool _buildMode; + bool _wantedBuildMode; + Panel* _mouseArenaPanel; + Cursor* _cursor[Cursor::DefaultCursor::dc_last]; + Cursor* _cursorOveride; +private: + long _nextTickMillis; + long _minimumTickMillisInterval; + friend class SurfaceBase; +}; +} + +#endif + + + diff --git a/utils/vgui/include/VGUI_Bitmap.h b/utils/vgui/include/VGUI_Bitmap.h new file mode 100644 index 00000000..04de3067 --- /dev/null +++ b/utils/vgui/include/VGUI_Bitmap.h @@ -0,0 +1,37 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_BITMAP_H +#define VGUI_BITMAP_H + +#include +#include + +namespace vgui +{ + +class Panel; + +class VGUIAPI Bitmap : public Image +{ +private: + int _id; + bool _uploaded; +public: + Bitmap(); +protected: + virtual void setSize(int wide,int tall); + virtual void setRGBA(int x,int y,uchar r,uchar g,uchar b,uchar a); +public: + virtual void paint(Panel* panel); +protected: + uchar* _rgba; +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_BitmapTGA.h b/utils/vgui/include/VGUI_BitmapTGA.h new file mode 100644 index 00000000..f0ecedb3 --- /dev/null +++ b/utils/vgui/include/VGUI_BitmapTGA.h @@ -0,0 +1,29 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_BITMAPTGA_H +#define VGUI_BITMAPTGA_H + +#include + +namespace vgui +{ + +class Panel; +class InputStream; + +class VGUIAPI BitmapTGA : public Bitmap +{ +public: + BitmapTGA(InputStream* is,bool invertAlpha); +private: + virtual bool loadTGA(InputStream* is,bool invertAlpha); +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_Border.h b/utils/vgui/include/VGUI_Border.h new file mode 100644 index 00000000..416b8787 --- /dev/null +++ b/utils/vgui/include/VGUI_Border.h @@ -0,0 +1,45 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_BORDER_H +#define VGUI_BORDER_H + +#include +#include + +//TODO: all borders should be titled + +namespace vgui +{ + +class Panel; + +class VGUIAPI Border : public Image +{ +public: + Border(); + Border(int left,int top,int right,int bottom); +public: + virtual void setInset(int left,int top,int right,int bottom); + virtual void getInset(int& left,int& top,int& right,int& bottom); +protected: + virtual void drawFilledRect(int x0,int y0,int x1,int y1); + virtual void drawOutlinedRect(int x0,int y0,int x1,int y1); + virtual void drawSetTextPos(int x,int y); + virtual void drawPrintText(int x,int y,const char* str,int strlen); + virtual void drawPrintChar(int x,int y,char ch); +protected: + int _inset[4]; +private: + Panel* _panel; +friend class Panel; +friend class BorderPair; +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_BorderLayout.h b/utils/vgui/include/VGUI_BorderLayout.h new file mode 100644 index 00000000..2d7678e1 --- /dev/null +++ b/utils/vgui/include/VGUI_BorderLayout.h @@ -0,0 +1,46 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_BORDERLAYOUT_H +#define VGUI_BORDERLAYOUT_H + +#include +#include + +namespace vgui +{ + +class LayoutInfo; + +class VGUIAPI BorderLayout : public Layout +{ +public: + enum Alignment + { + a_center=0, + a_north, + a_south, + a_east, + a_west, + }; +private: + int _inset; +public: + BorderLayout(int inset); +public: + virtual void performLayout(Panel* panel); + virtual LayoutInfo* createLayoutInfo(Alignment alignment); +}; + +} + +#endif + + + + + diff --git a/utils/vgui/include/VGUI_BorderPair.h b/utils/vgui/include/VGUI_BorderPair.h new file mode 100644 index 00000000..82318d48 --- /dev/null +++ b/utils/vgui/include/VGUI_BorderPair.h @@ -0,0 +1,33 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_BORDERPAIR_H +#define VGUI_BORDERPAIR_H + +#include +#include + +namespace vgui +{ + +class Panel; + +class VGUIAPI BorderPair : public Border +{ +public: + BorderPair(Border* border0,Border* border1); +public: + virtual void doPaint(Panel* panel); +protected: + virtual void paint(Panel* panel); +protected: + Border* _border[2]; +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_BuildGroup.h b/utils/vgui/include/VGUI_BuildGroup.h new file mode 100644 index 00000000..694ac5c4 --- /dev/null +++ b/utils/vgui/include/VGUI_BuildGroup.h @@ -0,0 +1,67 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_BUILDGROUP_H +#define VGUI_BUILDGROUP_H + +#include +#include + + +namespace vgui +{ + +enum KeyCode; +enum MouseCode; +class Panel; +class Cursor; +class ChangeSignal; + +class VGUIAPI BuildGroup +{ +private: + bool _enabled; + int _snapX; + int _snapY; + Cursor* _cursor_sizenwse; + Cursor* _cursor_sizenesw; + Cursor* _cursor_sizewe; + Cursor* _cursor_sizens; + Cursor* _cursor_sizeall; + bool _dragging; + MouseCode _dragMouseCode; + int _dragStartPanelPos[2]; + int _dragStartCursorPos[2]; + Panel* _currentPanel; + Dar _currentPanelChangeSignalDar; + Dar _panelDar; + Dar _panelNameDar; +public: + BuildGroup(); +public: + virtual void setEnabled(bool state); + virtual bool isEnabled(); + virtual void addCurrentPanelChangeSignal(ChangeSignal* s); + virtual Panel* getCurrentPanel(); + virtual void copyPropertiesToClipboard(); +private: + virtual void applySnap(Panel* panel); + virtual void fireCurrentPanelChangeSignal(); +protected: + friend class Panel; + virtual void panelAdded(Panel* panel,const char* panelName); + virtual void cursorMoved(int x,int y,Panel* panel); + virtual void mousePressed(MouseCode code,Panel* panel); + virtual void mouseReleased(MouseCode code,Panel* panel); + virtual void mouseDoublePressed(MouseCode code,Panel* panel); + virtual void keyTyped(KeyCode code,Panel* panel); + virtual Cursor* getCursor(Panel* panel); +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_Button.h b/utils/vgui/include/VGUI_Button.h new file mode 100644 index 00000000..7885192d --- /dev/null +++ b/utils/vgui/include/VGUI_Button.h @@ -0,0 +1,61 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_BUTTON_H +#define VGUI_BUTTON_H + +#include +#include +#include + +namespace vgui +{ + +enum MouseCode; +class ButtonController; +class ButtonGroup; +class ActionSignal; + +//TODO: Button should be derived from an AbstractButton +class VGUIAPI Button : public Label +{ +public: + Button(const char* text,int x,int y,int wide,int tall); + Button(const char* text,int x,int y); +private: + void init(); +public: + virtual void setSelected(bool state); + virtual void setSelectedDirect(bool state); + virtual void setArmed(bool state); + virtual bool isSelected(); + virtual void doClick(); + virtual void addActionSignal(ActionSignal* s); + virtual void setButtonGroup(ButtonGroup* buttonGroup); + virtual bool isArmed(); + virtual void setButtonBorderEnabled(bool state); + virtual void setMouseClickEnabled(MouseCode code,bool state); + virtual bool isMouseClickEnabled(MouseCode code); + virtual void fireActionSignal(); + virtual Panel* createPropertyPanel(); +protected: + virtual void setButtonController(ButtonController* _buttonController); + virtual void paintBackground(); +protected: + char* _text; + bool _armed; + bool _selected; + bool _buttonBorderEnabled; + Dar _actionSignalDar; + int _mouseClickMask; + ButtonGroup* _buttonGroup; + ButtonController* _buttonController; +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_ButtonController.h b/utils/vgui/include/VGUI_ButtonController.h new file mode 100644 index 00000000..f4f6d10f --- /dev/null +++ b/utils/vgui/include/VGUI_ButtonController.h @@ -0,0 +1,27 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_BUTTONCONTROLLER_H +#define VGUI_BUTTONCONTROLLER_H + +#include + +namespace vgui +{ + +class Button; + +class VGUIAPI ButtonController +{ +public: + virtual void addSignals(Button* button)=0; + virtual void removeSignals(Button* button)=0; +}; + +} + +#endif diff --git a/utils/vgui/include/VGUI_ButtonGroup.h b/utils/vgui/include/VGUI_ButtonGroup.h new file mode 100644 index 00000000..5f14bb4d --- /dev/null +++ b/utils/vgui/include/VGUI_ButtonGroup.h @@ -0,0 +1,30 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_BUTTONGROUP_H +#define VGUI_BUTTONGROUP_H + +#include +#include + +namespace vgui +{ + +class Button; + +class VGUIAPI ButtonGroup +{ +public: + virtual void addButton(Button* button); + virtual void setSelected(Button* button); +protected: + Dar _buttonDar; +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_ChangeSignal.h b/utils/vgui/include/VGUI_ChangeSignal.h new file mode 100644 index 00000000..85d6d279 --- /dev/null +++ b/utils/vgui/include/VGUI_ChangeSignal.h @@ -0,0 +1,26 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_CHANGESIGNAL_H +#define VGUI_CHANGESIGNAL_H + +#include + +namespace vgui +{ + +class Panel; + +class VGUIAPI ChangeSignal +{ +public: + virtual void valueChanged(Panel* panel)=0; +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_CheckButton.h b/utils/vgui/include/VGUI_CheckButton.h new file mode 100644 index 00000000..a3d71695 --- /dev/null +++ b/utils/vgui/include/VGUI_CheckButton.h @@ -0,0 +1,28 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_CHECKBUTTON_H +#define VGUI_CHECKBUTTON_H + +#include +#include + +namespace vgui +{ + +class VGUIAPI CheckButton : public ToggleButton +{ +public: + CheckButton(const char* text,int x,int y,int wide,int tall); + CheckButton(const char* text,int x,int y); +protected: + virtual void paintBackground(); +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_Color.h b/utils/vgui/include/VGUI_Color.h new file mode 100644 index 00000000..2ed676a8 --- /dev/null +++ b/utils/vgui/include/VGUI_Color.h @@ -0,0 +1,44 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_COLOR_H +#define VGUI_COLOR_H + +#include +#include + +//TODO: rename getColor(r,g,b,a) to getRGBA(r,g,b,a) +//TODO: rename setColor(r,g,b,a) to setRGBA(r,g,b,a) +//TODO: rename getColor(sc) to getSchemeColor(sc) +//TODO: rename setColor(sc) to setSchemeColor(sc) + +namespace vgui +{ + +class VGUIAPI Color +{ +private: + uchar _color[4]; + Scheme::SchemeColor _schemeColor; +public: + Color(); + Color(int r,int g,int b,int a); + Color(Scheme::SchemeColor sc); +private: + virtual void init(); +public: + virtual void setColor(int r,int g,int b,int a); + virtual void setColor(Scheme::SchemeColor sc); + virtual void getColor(int& r,int& g,int& b,int& a); + virtual void getColor(Scheme::SchemeColor& sc); + virtual int operator[](int index); +}; + +} + + +#endif diff --git a/utils/vgui/include/VGUI_ComboKey.h b/utils/vgui/include/VGUI_ComboKey.h new file mode 100644 index 00000000..adc8abf8 --- /dev/null +++ b/utils/vgui/include/VGUI_ComboKey.h @@ -0,0 +1,34 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_COMBOKEY_H +#define VGUI_COMBOKEY_H + +#include + +namespace vgui +{ + +enum KeyCode; + +class ComboKey +{ +public: + ComboKey(KeyCode code,KeyCode modifier); +public: + bool isTwoCombo(KeyCode code,KeyCode modifier); +protected: + bool check(KeyCode code); +protected: + KeyCode _keyCode[2]; +friend class Panel; +}; + +} + + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_ConfigWizard.h b/utils/vgui/include/VGUI_ConfigWizard.h new file mode 100644 index 00000000..713ecb4f --- /dev/null +++ b/utils/vgui/include/VGUI_ConfigWizard.h @@ -0,0 +1,40 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_CONFIGWIZARD_H +#define VGUI_CONFIGWIZARD_H + +#include +#include + +namespace vgui +{ + +class TreeFolder; +class Panel; +class Button; + +class VGUIAPI ConfigWizard : public Panel +{ +public: + ConfigWizard(int x,int y,int wide,int tall); +public: + virtual void setSize(int wide,int tall); + virtual Panel* getClient(); + virtual TreeFolder* getFolder(); +protected: + TreeFolder* _treeFolder; + Panel* _client; + Button* _okButton; + Button* _cancelButton; + Button* _applyButton; + Button* _helpButton; +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_Cursor.h b/utils/vgui/include/VGUI_Cursor.h new file mode 100644 index 00000000..44ae1114 --- /dev/null +++ b/utils/vgui/include/VGUI_Cursor.h @@ -0,0 +1,57 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_CURSOR_H +#define VGUI_CURSOR_H + +#include + +namespace vgui +{ + +class Bitmap; + +class VGUIAPI Cursor +{ +public: + enum DefaultCursor + { + dc_user, + dc_none, + dc_arrow, + dc_ibeam, + dc_hourglass, + dc_crosshair, + dc_up, + dc_sizenwse, + dc_sizenesw, + dc_sizewe, + dc_sizens, + dc_sizeall, + dc_no, + dc_hand, + dc_last, + }; +private: + int _hotspot[2]; + Bitmap* _bitmap; + DefaultCursor _dc; +public: + Cursor(DefaultCursor dc); + Cursor(Bitmap* bitmap,int hotspotX,int hotspotY); +public: + virtual void getHotspot(int& x,int& y); +private: + virtual void privateInit(Bitmap* bitmap,int hotspotX,int hotspotY); +public: + virtual Bitmap* getBitmap(); + virtual DefaultCursor getDefaultCursor(); +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_Dar.h b/utils/vgui/include/VGUI_Dar.h new file mode 100644 index 00000000..c0f1990d --- /dev/null +++ b/utils/vgui/include/VGUI_Dar.h @@ -0,0 +1,193 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_DAR_H +#define VGUI_DAR_H + +#include +#include +#include + + + +namespace vgui +{ + +//Simple lightweight dynamic array implementation +template class VGUIAPI Dar +{ +public: + Dar() + { + _count=0; + _capacity=0; + _data=null; + ensureCapacity(4); + } + Dar(int initialCapacity) + { + _count=0; + _capacity=0; + _data=null; + ensureCapacity(initialCapacity); + } +public: + void ensureCapacity(int wantedCapacity) + { + if(wantedCapacity<=_capacity){return;} + + //double capacity until it is >= wantedCapacity + //this could be done with math, but iterative is just so much more fun + int newCapacity=_capacity; + if(newCapacity==0){newCapacity=1;} + while(newCapacity_capacity)) + { + return; + } + _count=count; + } + int getCount() + { + return _count; + } + void addElement(ELEMTYPE elem) + { + ensureCapacity(_count+1); + _data[_count]=elem; + _count++; + } + bool hasElement(ELEMTYPE elem) + { + for(int i=0;i<_count;i++) + { + if(_data[i]==elem) + { + return true; + } + } + return false; + } + void putElement(ELEMTYPE elem) + { + if(hasElement(elem)) + { + return; + } + addElement(elem); + } + void insertElementAt(ELEMTYPE elem,int index) + { + if((index<0)||(index>_count)) + { + return; + } + if((index==_count)||(_count==0)) + { + addElement(elem); + } + else + { + addElement(elem); //just to make sure it is big enough + for(int i=_count-1;i>index;i--) + { + _data[i]=_data[i-1]; + } + _data[index]=elem; + } + } + void setElementAt(ELEMTYPE elem,int index) + { + if((index<0)||(index>=_count)) + { + return; + } + _data[index]=elem; + } + void removeElementAt(int index) + { + if((index<0)||(index>=_count)) + { + return; + } + + //slide everything to the right of index, left one. + for(int i=index;i<(_count-1);i++) + { + _data[i]=_data[i+1]; + } + _count--; + } + void removeElement(ELEMTYPE elem) + { + for(int i=0;i<_count;i++) + { + if(_data[i]==elem) + { + removeElementAt(i); + break; + } + } + } + void removeAll() + { + _count=0; + } + ELEMTYPE operator[](int index) + { + if((index<0)||(index>=_count)) + { + return null; + } + return _data[index]; + } +protected: + int _count; + int _capacity; + ELEMTYPE* _data; +}; + +//forward referencing all the template types used so they get exported +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar*>; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; + + +} + + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_DataInputStream.h b/utils/vgui/include/VGUI_DataInputStream.h new file mode 100644 index 00000000..dba1acf0 --- /dev/null +++ b/utils/vgui/include/VGUI_DataInputStream.h @@ -0,0 +1,49 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_DATAINPUTSTREAM_H +#define VGUI_DATAINPUTSTREAM_H + +#include +#include + +namespace vgui +{ + +class VGUIAPI DataInputStream : virtual public InputStream +{ +private: + InputStream* _is; +public: + DataInputStream(InputStream* is); +public: + virtual void seekStart(bool& success); + virtual void seekRelative(int count,bool& success); + virtual void seekEnd(bool& success); + virtual int getAvailable(bool& success); + //virtual uchar readUChar(bool& success); + virtual void readUChar(uchar* buf,int count,bool& success); + virtual void close(bool& success); + virtual void close(); +public: + virtual bool readBool(bool& success); + virtual char readChar(bool& success); + virtual uchar readUChar(bool& success); + virtual short readShort(bool& success); + virtual ushort readUShort(bool& success); + virtual int readInt(bool& success); + virtual uint readUInt(bool& success); + virtual long readLong(bool& success); + virtual ulong readULong(bool& success); + virtual float readFloat(bool& success); + virtual double readDouble(bool& success); + virtual void readLine(char* buf,int bufLen,bool& success); +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_Desktop.h b/utils/vgui/include/VGUI_Desktop.h new file mode 100644 index 00000000..da8e0d00 --- /dev/null +++ b/utils/vgui/include/VGUI_Desktop.h @@ -0,0 +1,42 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_DESKTOP_H +#define VGUI_DESKTOP_H + +#include +#include +#include + +namespace vgui +{ + +class DesktopIcon; +class TaskBar; + +class VGUIAPI Desktop : public Panel +{ +public: + Desktop(int x,int y,int wide,int tall); +public: + virtual void setSize(int wide,int tall); + virtual void iconActivated(DesktopIcon* icon); + virtual void addIcon(DesktopIcon* icon); + virtual void arrangeIcons(); + virtual Panel* getBackground(); + virtual Panel* getForeground(); +protected: + Panel* _background; + Panel* _foreground; + TaskBar* _taskBar; + Dar _desktopIconDar; + int _cascade[2]; +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_DesktopIcon.h b/utils/vgui/include/VGUI_DesktopIcon.h new file mode 100644 index 00000000..192fef45 --- /dev/null +++ b/utils/vgui/include/VGUI_DesktopIcon.h @@ -0,0 +1,41 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_DESKTOPICON_H +#define VGUI_DESKTOPICON_H + +#include +#include + +namespace vgui +{ + +class MiniApp; +class Image; +class Desktop; + +class VGUIAPI DesktopIcon : public Panel +{ +public: + DesktopIcon(MiniApp* miniApp,Image* image); +public: + virtual void doActivate(); + virtual void setImage(Image* image); +public: //bullshit public + virtual void setDesktop(Desktop* desktop); + virtual MiniApp* getMiniApp(); +protected: + virtual void paintBackground(); +protected: + Desktop* _desktop; + MiniApp* _miniApp; + Image* _image; +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_EditPanel.h b/utils/vgui/include/VGUI_EditPanel.h new file mode 100644 index 00000000..23e29263 --- /dev/null +++ b/utils/vgui/include/VGUI_EditPanel.h @@ -0,0 +1,65 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_EDITPANEL_H +#define VGUI_EDITPANEL_H + +#include +#include +#include + +namespace vgui +{ + +class Font; + +class VGUIAPI EditPanel : public Panel +{ +public: + EditPanel(int x,int y,int wide,int tall); +public: + virtual void doCursorUp(); + virtual void doCursorDown(); + virtual void doCursorLeft(); + virtual void doCursorRight(); + virtual void doCursorToStartOfLine(); + virtual void doCursorToEndOfLine(); + virtual void doCursorInsertChar(char ch); + virtual void doCursorBackspace(); + virtual void doCursorNewLine(); + virtual void doCursorDelete(); + virtual void doCursorPrintf(char* format,...); + virtual int getLineCount(); + virtual int getVisibleLineCount(); + virtual void setCursorBlink(bool state); + virtual void setFont(Font* font); + virtual void getText(int lineIndex, int offset,char* buf,int bufLen); + +public: //bullshit public + void getCursorBlink(bool& blink,int& nextBlinkTime); +protected: + virtual void paintBackground(); + virtual void paint(); + virtual void addLine(); + virtual Dar* getLine(int lineIndex); + virtual void setChar(Dar* lineDar,int x,char ch,char fill); + virtual void setChar(Dar* lineDar,int x,char ch); + virtual void shiftLineLeft(Dar* lineDar,int x,int count); + virtual void shiftLineRight(Dar* lineDar,int x,int count); +private: + virtual int spatialCharOffsetBetweenTwoLines(Dar* srcDar,Dar* dstDar,int x); +protected: + Dar*> _lineDarDar; + int _cursor[2]; + bool _cursorBlink; + int _cursorNextBlinkTime; + Font* _font; +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_EtchedBorder.h b/utils/vgui/include/VGUI_EtchedBorder.h new file mode 100644 index 00000000..7047c087 --- /dev/null +++ b/utils/vgui/include/VGUI_EtchedBorder.h @@ -0,0 +1,29 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_ETCHEDBORDER_H +#define VGUI_ETCHEDBORDER_H + +#include +#include + +namespace vgui +{ + +class Panel; + +class VGUIAPI EtchedBorder : public Border +{ +public: + EtchedBorder(); +protected: + virtual void paint(Panel* panel); +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_FileInputStream.h b/utils/vgui/include/VGUI_FileInputStream.h new file mode 100644 index 00000000..41b60868 --- /dev/null +++ b/utils/vgui/include/VGUI_FileInputStream.h @@ -0,0 +1,38 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_FILEINPUTSTREAM_H +#define VGUI_FILEINPUTSTREAM_H + +//TODO : figure out how to get stdio out of here, I think std namespace is broken for FILE for forward declaring does not work in vc6 + +#include +#include + +namespace vgui +{ + +class VGUIAPI FileInputStream : public InputStream +{ +private: + FILE* _fp; +public: + FileInputStream(const char* fileName,bool textMode); +public: + virtual void seekStart(bool& success); + virtual void seekRelative(int count,bool& success); + virtual void seekEnd(bool& success); + virtual int getAvailable(bool& success); + virtual uchar readUChar(bool& success); + virtual void readUChar(uchar* buf,int count,bool& success); + virtual void close(bool& success); + virtual void close(); +}; + +} + +#endif diff --git a/utils/vgui/include/VGUI_FlowLayout.h b/utils/vgui/include/VGUI_FlowLayout.h new file mode 100644 index 00000000..c9585657 --- /dev/null +++ b/utils/vgui/include/VGUI_FlowLayout.h @@ -0,0 +1,29 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_FLOWLAYOUT_H +#define VGUI_FLOWLAYOUT_H + +#include +#include + +namespace vgui +{ + +class VGUIAPI FlowLayout : public Layout +{ +private: + int _hgap; +public: + FlowLayout(int hgap); +public: + virtual void performLayout(Panel* panel); +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_FocusChangeSignal.h b/utils/vgui/include/VGUI_FocusChangeSignal.h new file mode 100644 index 00000000..0681f8ab --- /dev/null +++ b/utils/vgui/include/VGUI_FocusChangeSignal.h @@ -0,0 +1,26 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_FOCUSCHANGESIGNAL_H +#define VGUI_FOCUSCHANGESIGNAL_H + +#include + +namespace vgui +{ + +class Panel; + +class VGUIAPI FocusChangeSignal +{ +public: + virtual void focusChanged(bool lost,Panel* panel)=0; +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_FocusNavGroup.h b/utils/vgui/include/VGUI_FocusNavGroup.h new file mode 100644 index 00000000..b7e8307e --- /dev/null +++ b/utils/vgui/include/VGUI_FocusNavGroup.h @@ -0,0 +1,35 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_FOCUSNAVGROUP_H +#define VGUI_FOCUSNAVGROUP_H + +#include +#include + +namespace vgui +{ + +class Panel; + +class VGUIAPI FocusNavGroup +{ +public: + FocusNavGroup(); +protected: + virtual void addPanel(Panel* panel); + virtual void requestFocusPrev(); + virtual void requestFocusNext(); + virtual void setCurrentPanel(Panel* panel); +protected: + Dar _panelDar; + int _currentIndex; +friend class Panel; +}; +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_Font.h b/utils/vgui/include/VGUI_Font.h new file mode 100644 index 00000000..822722cf --- /dev/null +++ b/utils/vgui/include/VGUI_Font.h @@ -0,0 +1,48 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_FONT_H +#define VGUI_FONT_H + +#include + +namespace vgui +{ + +class BaseFontPlat; + +//TODO: cursors and fonts should work like gl binds +class VGUIAPI Font + { + public: + Font(const char* name,int tall,int wide,float rotation,int weight,bool italic,bool underline,bool strikeout,bool symbol); + // If pFileData is non-NULL, then it will try to load the 32-bit (RLE) TGA file. If that fails, + // it will create the font using the specified parameters. + // pUniqueName should be set if pFileData and fileDataLen are set so it can determine if a font is already loaded. + Font(const char* name,void *pFileData,int fileDataLen, int tall,int wide,float rotation,int weight,bool italic,bool underline,bool strikeout,bool symbol); + private: + virtual void init(const char* name,void *pFileData,int fileDataLen, int tall,int wide,float rotation,int weight,bool italic,bool underline,bool strikeout,bool symbol); + public: + BaseFontPlat* getPlat(); + virtual void getCharRGBA(int ch,int rgbaX,int rgbaY,int rgbaWide,int rgbaTall,uchar* rgba); + virtual void getCharABCwide(int ch,int& a,int& b,int& c); + virtual void getTextSize(const char* text,int& wide,int& tall); + virtual int getTall(); + virtual int getId(); + protected: + char* _name; + BaseFontPlat* _plat; + int _id; + friend class Surface; + }; + + +void Font_Reset(); + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_Frame.h b/utils/vgui/include/VGUI_Frame.h new file mode 100644 index 00000000..ffe41f87 --- /dev/null +++ b/utils/vgui/include/VGUI_Frame.h @@ -0,0 +1,73 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_FRAME_H +#define VGUI_FRAME_H + +#include +#include +#include + +namespace vgui +{ + +class Button; +class FrameSignal; + +class VGUIAPI Frame : public Panel + { + public: + Frame(int x,int y,int wide,int tall); + public: + virtual void setSize(int wide,int tall); + virtual void setInternal(bool state); + virtual void paintBackground(); + virtual bool isInternal(); + virtual Panel* getClient(); + virtual void setTitle(const char* title); + virtual void getTitle(char* buf,int bufLen); + virtual void setMoveable(bool state); + virtual void setSizeable(bool state); + virtual bool isMoveable(); + virtual bool isSizeable(); + virtual void addFrameSignal(FrameSignal* s); + virtual void setVisible(bool state); + virtual void setMenuButtonVisible(bool state); + virtual void setTrayButtonVisible(bool state); + virtual void setMinimizeButtonVisible(bool state); + virtual void setMaximizeButtonVisible(bool state); + virtual void setCloseButtonVisible(bool state); + public: //bullshit public + virtual void fireClosingSignal(); + virtual void fireMinimizingSignal(); + protected: + char* _title; + bool _internal; + bool _sizeable; + bool _moveable; + Panel* _topGrip; + Panel* _bottomGrip; + Panel* _leftGrip; + Panel* _rightGrip; + Panel* _topLeftGrip; + Panel* _topRightGrip; + Panel* _bottomLeftGrip; + Panel* _bottomRightGrip; + Panel* _captionGrip; + Panel* _client; + Button* _trayButton; + Button* _minimizeButton; + Button* _maximizeButton; + Button* _closeButton; + Button* _menuButton; + Dar _frameSignalDar; + Frame* _resizeable; + }; + +} + +#endif diff --git a/utils/vgui/include/VGUI_FrameSignal.h b/utils/vgui/include/VGUI_FrameSignal.h new file mode 100644 index 00000000..7deab555 --- /dev/null +++ b/utils/vgui/include/VGUI_FrameSignal.h @@ -0,0 +1,27 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_FRAMESIGNAL_H +#define VGUI_FRAMESIGNAL_H + +#include + +namespace vgui +{ + +class Frame; + +class VGUIAPI FrameSignal +{ +public: + virtual void closing(Frame* frame)=0; + virtual void minimizing(Frame* frame,bool toTray)=0; +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_GridLayout.h b/utils/vgui/include/VGUI_GridLayout.h new file mode 100644 index 00000000..946159dd --- /dev/null +++ b/utils/vgui/include/VGUI_GridLayout.h @@ -0,0 +1,30 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_GRIDLAYOUT_H +#define VGUI_GRIDLAYOUT_H + +#include +#include + +namespace vgui +{ + +/* +class VGUIAPI GridLayout : public Layout +{ +public: + GridLayout(int rows,int cols,int hgap,int vgap); +protected: + int _rows; + int _cols; +}; +*/ + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_HeaderPanel.h b/utils/vgui/include/VGUI_HeaderPanel.h new file mode 100644 index 00000000..163d88f7 --- /dev/null +++ b/utils/vgui/include/VGUI_HeaderPanel.h @@ -0,0 +1,65 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_HEADERPANEL_H +#define VGUI_HEADERPANEL_H + +#include +#include +#include +#include + +namespace vgui +{ + +enum MouseCode; +class ChangeSignal; + +class VGUIAPI HeaderPanel : public Panel +{ + +private: + + Dar _sliderPanelDar; + Dar _sectionPanelDar; + Dar _changeSignalDar; + Panel* _sectionLayer; + int _sliderWide; + bool _dragging; + int _dragSliderIndex; + int _dragSliderStartPos; + int _dragSliderStartX; + +public: + + HeaderPanel(int x,int y,int wide,int tall); + +protected: + + virtual void performLayout(); + +public: + + virtual void addSectionPanel(Panel* panel); + virtual void setSliderPos(int sliderIndex,int pos); + virtual int getSectionCount(); + virtual void getSectionExtents(int sectionIndex,int& x0,int& x1); + virtual void addChangeSignal(ChangeSignal* s); + +public: //bullshit public + + virtual void fireChangeSignal(); + virtual void privateCursorMoved(int x,int y,Panel* panel); + virtual void privateMousePressed(MouseCode code,Panel* panel); + virtual void privateMouseReleased(MouseCode code,Panel* panel); + +}; + +} + +#endif + diff --git a/utils/vgui/include/VGUI_Image.h b/utils/vgui/include/VGUI_Image.h new file mode 100644 index 00000000..8250a87a --- /dev/null +++ b/utils/vgui/include/VGUI_Image.h @@ -0,0 +1,62 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_IMAGE_H +#define VGUI_IMAGE_H + +#include +#include +#include + +//TODO:: needs concept of insets + +namespace vgui +{ + +class Panel; + +class VGUIAPI Image +{ +friend class Panel; +private: + int _pos[2]; + int _size[2]; + Panel* _panel; + Color _color; +public: + Image(); +public: + virtual void setPos(int x,int y); + virtual void getPos(int& x,int& y); + virtual void getSize(int& wide,int& tall); + virtual void setColor(Color color); + virtual void getColor(Color& color); +protected: + virtual void setSize(int wide,int tall); + virtual void drawSetColor(Scheme::SchemeColor sc); + virtual void drawSetColor(int r,int g,int b,int a); + virtual void drawFilledRect(int x0,int y0,int x1,int y1); + virtual void drawOutlinedRect(int x0,int y0,int x1,int y1); + virtual void drawSetTextFont(Scheme::SchemeFont sf); + virtual void drawSetTextFont(Font* font); + virtual void drawSetTextColor(Scheme::SchemeColor sc); + virtual void drawSetTextColor(int r,int g,int b,int a); + virtual void drawSetTextPos(int x,int y); + virtual void drawPrintText(const char* str,int strlen); + virtual void drawPrintText(int x,int y,const char* str,int strlen); + virtual void drawPrintChar(char ch); + virtual void drawPrintChar(int x,int y,char ch); + virtual void drawSetTextureRGBA(int id,const char* rgba,int wide,int tall); + virtual void drawSetTexture(int id); + virtual void drawTexturedRect(int x0,int y0,int x1,int y1); + virtual void paint(Panel* panel); +public: + virtual void doPaint(Panel* panel); +}; +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_ImagePanel.h b/utils/vgui/include/VGUI_ImagePanel.h new file mode 100644 index 00000000..cb492cd5 --- /dev/null +++ b/utils/vgui/include/VGUI_ImagePanel.h @@ -0,0 +1,38 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_IMAGEPANEL_H +#define VGUI_IMAGEPANEL_H + +#include +#include + +namespace vgui +{ + +class Image; + +class VGUIAPI ImagePanel : public Panel +{ +public: + inline ImagePanel() + { + _image=null; + } + + ImagePanel(Image* image); +public: + virtual void setImage(Image* image); +protected: + virtual void paintBackground(); +protected: + Image* _image; +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_InputSignal.h b/utils/vgui/include/VGUI_InputSignal.h new file mode 100644 index 00000000..d5fc02a9 --- /dev/null +++ b/utils/vgui/include/VGUI_InputSignal.h @@ -0,0 +1,39 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_INPUTSIGNAL_H +#define VGUI_INPUTSIGNAL_H + +#include + +namespace vgui +{ + +enum MouseCode; +enum KeyCode; +class Panel; + +//these are lumped into one for simplicity sake right now +class VGUIAPI InputSignal +{ +public: + virtual void cursorMoved(int x,int y,Panel* panel)=0; + virtual void cursorEntered(Panel* panel)=0; + virtual void cursorExited(Panel* panel)=0; + virtual void mousePressed(MouseCode code,Panel* panel)=0; + virtual void mouseDoublePressed(MouseCode code,Panel* panel)=0; + virtual void mouseReleased(MouseCode code,Panel* panel)=0; + virtual void mouseWheeled(int delta,Panel* panel)=0; + virtual void keyPressed(KeyCode code,Panel* panel)=0; + virtual void keyTyped(KeyCode code,Panel* panel)=0; + virtual void keyReleased(KeyCode code,Panel* panel)=0; + virtual void keyFocusTicked(Panel* panel)=0; +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_InputStream.h b/utils/vgui/include/VGUI_InputStream.h new file mode 100644 index 00000000..141e9e2e --- /dev/null +++ b/utils/vgui/include/VGUI_InputStream.h @@ -0,0 +1,30 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_FILE_H +#define VGUI_FILE_H + +#include + +namespace vgui +{ + +class VGUIAPI InputStream +{ +public: + virtual void seekStart(bool& success)=0; + virtual void seekRelative(int count,bool& success)=0; + virtual void seekEnd(bool& success)=0; + virtual int getAvailable(bool& success)=0; + virtual uchar readUChar(bool& success)=0; + virtual void readUChar(uchar* buf,int count,bool& success)=0; + virtual void close(bool& success)=0; +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_IntChangeSignal.h b/utils/vgui/include/VGUI_IntChangeSignal.h new file mode 100644 index 00000000..9aa4d49e --- /dev/null +++ b/utils/vgui/include/VGUI_IntChangeSignal.h @@ -0,0 +1,26 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_INTCHANGESIGNAL_H +#define VGUI_INTCHANGESIGNAL_H + +#include + +namespace vgui +{ + +class Panel; + +class VGUIAPI IntChangeSignal +{ +public: + virtual void intChanged(int value,Panel* panel)=0; +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_IntLabel.h b/utils/vgui/include/VGUI_IntLabel.h new file mode 100644 index 00000000..275b3cea --- /dev/null +++ b/utils/vgui/include/VGUI_IntLabel.h @@ -0,0 +1,35 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_INTLABEL_H +#define VGUI_INTLABEL_H + +#include +#include +#include + +namespace vgui +{ + +class Panel; + +class VGUIAPI IntLabel : public Label , public IntChangeSignal +{ +public: + IntLabel(int value,int x,int y,int wide,int tall); +public: + virtual void setValue(int value); + virtual void intChanged(int value,Panel* panel); +protected: + virtual void paintBackground(); +protected: + int _value; +}; + +} + +#endif diff --git a/utils/vgui/include/VGUI_KeyCode.h b/utils/vgui/include/VGUI_KeyCode.h new file mode 100644 index 00000000..f100cd42 --- /dev/null +++ b/utils/vgui/include/VGUI_KeyCode.h @@ -0,0 +1,126 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_KEYCODE_H +#define VGUI_KEYCODE_H + +#include + +namespace vgui +{ +enum VGUIAPI KeyCode +{ + KEY_0=0, + KEY_1, + KEY_2, + KEY_3, + KEY_4, + KEY_5, + KEY_6, + KEY_7, + KEY_8, + KEY_9, + KEY_A, + KEY_B, + KEY_C, + KEY_D, + KEY_E, + KEY_F, + KEY_G, + KEY_H, + KEY_I, + KEY_J, + KEY_K, + KEY_L, + KEY_M, + KEY_N, + KEY_O, + KEY_P, + KEY_Q, + KEY_R, + KEY_S, + KEY_T, + KEY_U, + KEY_V, + KEY_W, + KEY_X, + KEY_Y, + KEY_Z, + KEY_PAD_0, + KEY_PAD_1, + KEY_PAD_2, + KEY_PAD_3, + KEY_PAD_4, + KEY_PAD_5, + KEY_PAD_6, + KEY_PAD_7, + KEY_PAD_8, + KEY_PAD_9, + KEY_PAD_DIVIDE, + KEY_PAD_MULTIPLY, + KEY_PAD_MINUS, + KEY_PAD_PLUS, + KEY_PAD_ENTER, + KEY_PAD_DECIMAL, + KEY_LBRACKET, + KEY_RBRACKET, + KEY_SEMICOLON, + KEY_APOSTROPHE, + KEY_BACKQUOTE, + KEY_COMMA, + KEY_PERIOD, + KEY_SLASH, + KEY_BACKSLASH, + KEY_MINUS, + KEY_EQUAL, + KEY_ENTER, + KEY_SPACE, + KEY_BACKSPACE, + KEY_TAB, + KEY_CAPSLOCK, + KEY_NUMLOCK, + KEY_ESCAPE, + KEY_SCROLLLOCK, + KEY_INSERT, + KEY_DELETE, + KEY_HOME, + KEY_END, + KEY_PAGEUP, + KEY_PAGEDOWN, + KEY_BREAK, + KEY_LSHIFT, + KEY_RSHIFT, + KEY_LALT, + KEY_RALT, + KEY_LCONTROL, + KEY_RCONTROL, + KEY_LWIN, + KEY_RWIN, + KEY_APP, + KEY_UP, + KEY_LEFT, + KEY_DOWN, + KEY_RIGHT, + KEY_F1, + KEY_F2, + KEY_F3, + KEY_F4, + KEY_F5, + KEY_F6, + KEY_F7, + KEY_F8, + KEY_F9, + KEY_F10, + KEY_F11, + KEY_F12, + KEY_LAST, +}; +} + + +#endif + diff --git a/utils/vgui/include/VGUI_Label.h b/utils/vgui/include/VGUI_Label.h new file mode 100644 index 00000000..af90e9f8 --- /dev/null +++ b/utils/vgui/include/VGUI_Label.h @@ -0,0 +1,80 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_LABEL_H +#define VGUI_LABEL_H + +#include +#include +#include + +//TODO: this should use a TextImage for the text + +namespace vgui +{ + +class Panel; +class TextImage; + +class VGUIAPI Label : public Panel +{ +public: + enum Alignment + { + a_northwest=0, + a_north, + a_northeast, + a_west, + a_center, + a_east, + a_southwest, + a_south, + a_southeast, + }; +public: + Label(int textBufferLen,const char* text,int x,int y,int wide,int tall); + Label(const char* text,int x,int y,int wide,int tall); + Label(const char* text,int x,int y); + Label(const char* text); + + inline Label() : Panel(0,0,10,10) + { + init(1,"",true); + } +private: + void init(int textBufferLen,const char* text,bool textFitted); +public: + virtual void setImage(Image* image); + virtual void setText(int textBufferLen,const char* text); + virtual void setText(const char* format,...); + virtual void setFont(Scheme::SchemeFont schemeFont); + virtual void setFont(Font* font); + virtual void getTextSize(int& wide,int& tall); + virtual void getContentSize(int& wide,int& tall); + virtual void setTextAlignment(Alignment alignment); + virtual void setContentAlignment(Alignment alignment); + virtual Panel* createPropertyPanel(); + virtual void setFgColor(int r,int g,int b,int a); + virtual void setFgColor(vgui::Scheme::SchemeColor sc); + virtual void setContentFitted(bool state); +protected: + virtual void computeAlignment(int& tx0,int& ty0,int& tx1,int& ty1,int& ix0,int& iy0,int& ix1,int& iy1,int& minX,int& minY,int& maxX,int& maxY); + virtual void paint(); + virtual void recomputeMinimumSize(); +protected: + bool _textEnabled; + bool _imageEnabled; + bool _contentFitted; + Alignment _textAlignment; + Alignment _contentAlignment; + TextImage* _textImage; + Image* _image; +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_Layout.h b/utils/vgui/include/VGUI_Layout.h new file mode 100644 index 00000000..081c2ec1 --- /dev/null +++ b/utils/vgui/include/VGUI_Layout.h @@ -0,0 +1,31 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_LAYOUT_H +#define VGUI_LAYOUT_H + +#include + +namespace vgui +{ + +class Panel; + +class VGUIAPI Layout +{ +//private: +// Panel* _panel; +public: + Layout(); +public: + //virtual void setPanel(Panel* panel); //called by Panel::setLayout + virtual void performLayout(Panel* panel); +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_LayoutInfo.h b/utils/vgui/include/VGUI_LayoutInfo.h new file mode 100644 index 00000000..569be760 --- /dev/null +++ b/utils/vgui/include/VGUI_LayoutInfo.h @@ -0,0 +1,21 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_LAYOUTINFO_H +#define VGUI_LAYOUTINFO_H + +namespace vgui +{ + +class VGUIAPI LayoutInfo +{ + virtual LayoutInfo* getThis()=0; +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_LineBorder.h b/utils/vgui/include/VGUI_LineBorder.h new file mode 100644 index 00000000..1263a46e --- /dev/null +++ b/utils/vgui/include/VGUI_LineBorder.h @@ -0,0 +1,39 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_LINEBORDER_H +#define VGUI_LINEBORDER_H + +#include +#include +#include + +namespace vgui +{ + +class Panel; + +class VGUIAPI LineBorder : public Border +{ +private: + Color _color; +public: + LineBorder(); + LineBorder(int thickness); + LineBorder(Color color); + LineBorder(int thickness,Color color); + + inline void setLineColor(int r, int g, int b, int a) {_color = Color(r,g,b,a);} +private: + virtual void init(int thickness,Color color); +protected: + virtual void paint(Panel* panel); +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_ListPanel.h b/utils/vgui/include/VGUI_ListPanel.h new file mode 100644 index 00000000..542f5bde --- /dev/null +++ b/utils/vgui/include/VGUI_ListPanel.h @@ -0,0 +1,40 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_LISTPANEL_H +#define VGUI_LISTPANEL_H + +#include +#include + +namespace vgui +{ + +class ScrollBar; + +//TODO: make a ScrollPanel and use a constrained one for _vpanel in ListPanel +class VGUIAPI ListPanel : public Panel +{ +public: + ListPanel(int x,int y,int wide,int tall); +public: + virtual void setSize(int wide,int tall); + virtual void addString(const char* str); + virtual void addItem(Panel* panel); + virtual void setPixelScroll(int value); + virtual void translatePixelScroll(int delta); +protected: + virtual void performLayout(); + virtual void paintBackground(); +protected: + Panel* _vpanel; + ScrollBar* _scroll; +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_LoweredBorder.h b/utils/vgui/include/VGUI_LoweredBorder.h new file mode 100644 index 00000000..85ed51c0 --- /dev/null +++ b/utils/vgui/include/VGUI_LoweredBorder.h @@ -0,0 +1,29 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_LOWEREDBORDER_H +#define VGUI_LOWEREDBORDER_H + +#include +#include + +namespace vgui +{ + +class Panel; + +class VGUIAPI LoweredBorder : public Border +{ +public: + LoweredBorder(); +protected: + virtual void paint(Panel* panel); +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_Menu.h b/utils/vgui/include/VGUI_Menu.h new file mode 100644 index 00000000..035c1485 --- /dev/null +++ b/utils/vgui/include/VGUI_Menu.h @@ -0,0 +1,30 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_MENU_H +#define VGUI_MENU_H + +#include +#include + +namespace vgui +{ + +class Panel; + +class VGUIAPI Menu : public Panel +{ +public: + Menu(int x,int y,int wide,int tall); + Menu(int wide,int tall); +public: + virtual void addMenuItem(Panel* panel); +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_MenuItem.h b/utils/vgui/include/VGUI_MenuItem.h new file mode 100644 index 00000000..33cfa275 --- /dev/null +++ b/utils/vgui/include/VGUI_MenuItem.h @@ -0,0 +1,30 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_MENUITEM_H +#define VGUI_MENUITEM_H + +#include +#include + +namespace vgui +{ + +class Menu; + +class VGUIAPI MenuItem : public Button +{ +public: + MenuItem(const char* text); + MenuItem(const char* text,Menu* subMenu); +protected: + Menu* _subMenu; +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_MenuSeparator.h b/utils/vgui/include/VGUI_MenuSeparator.h new file mode 100644 index 00000000..f183a974 --- /dev/null +++ b/utils/vgui/include/VGUI_MenuSeparator.h @@ -0,0 +1,27 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_MENUSEPARATOR_H +#define VGUI_MENUSEPARATOR_H + +#include +#include + +namespace vgui +{ + +class VGUIAPI MenuSeparator : public Label +{ +public: + MenuSeparator(const char* text); +protected: + virtual void paintBackground(); +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_MessageBox.h b/utils/vgui/include/VGUI_MessageBox.h new file mode 100644 index 00000000..38a6e3c4 --- /dev/null +++ b/utils/vgui/include/VGUI_MessageBox.h @@ -0,0 +1,53 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_MESSAGEBOX_H +#define VGUI_MESSAGEBOX_H + +#include +#include +#include + + +namespace vgui +{ + +class Label; +class Button; +class ActionSignal; + +class VGUIAPI MessageBox : public Frame +{ + +private: + + Label* _messageLabel; + Button* _okButton; + Dar _actionSignalDar; + +public: + + MessageBox(const char* title,const char* text,int x,int y); + +protected: + + virtual void performLayout(); + +public: + + virtual void addActionSignal(ActionSignal* s); + virtual void fireActionSignal(); + +}; + +} + + + + + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_MiniApp.h b/utils/vgui/include/VGUI_MiniApp.h new file mode 100644 index 00000000..b7ce6682 --- /dev/null +++ b/utils/vgui/include/VGUI_MiniApp.h @@ -0,0 +1,33 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_MINIAPP_H +#define VGUI_MINIAPP_H + +#include + +namespace vgui +{ + +class Frame; + +class VGUIAPI MiniApp +{ +public: + MiniApp(); +public: + virtual void getName(char* buf,int bufLen); + virtual Frame* createInstance()=0; +protected: + virtual void setName(const char* name); +protected: + char* _name; +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_MouseCode.h b/utils/vgui/include/VGUI_MouseCode.h new file mode 100644 index 00000000..8adf8641 --- /dev/null +++ b/utils/vgui/include/VGUI_MouseCode.h @@ -0,0 +1,24 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_MOUSECODE_H +#define VGUI_MOUSECODE_H + +#include + +namespace vgui +{ +enum VGUIAPI MouseCode +{ + MOUSE_LEFT=0, + MOUSE_RIGHT, + MOUSE_MIDDLE, + MOUSE_LAST, +}; +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_Panel.h b/utils/vgui/include/VGUI_Panel.h new file mode 100644 index 00000000..d5cbd7b4 --- /dev/null +++ b/utils/vgui/include/VGUI_Panel.h @@ -0,0 +1,224 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_PANEL_H +#define VGUI_PANEL_H + + +/* + +TODO: + +Maybe have the border know who they are added to. +A border can only be added to 1 thing, and will be +removed from the other. That way they can actually +be memory managed. Also do Layout's this way too. + +TODO: + outlinedRect should have a thickness arg + +*/ + + +#include +#include +#include +#include + +namespace vgui +{ + +enum KeyCode; +enum MouseCode; +class SurfaceBase; +class FocusChangeSignal; +class InputSignal; +class Cursor; +class Layout; +class FocusNavGroup; +class Border; +class Font; +class BuildGroup; +class App; +class LayoutInfo; + +class VGUIAPI Panel +{ +public: + Panel(); + Panel(int x,int y,int wide,int tall); +private: + void init(int x,int y,int wide,int tall); +public: + virtual void setPos(int x,int y); + virtual void getPos(int& x,int& y); + virtual void setSize(int wide,int tall); + virtual void getSize(int& wide,int& tall); + virtual void setBounds(int x,int y,int wide,int tall); + virtual void getBounds(int& x,int& y,int& wide,int& tall); + virtual int getWide(); + virtual int getTall(); + virtual Panel* getParent(); + virtual void setVisible(bool state); + virtual bool isVisible(); + virtual bool isVisibleUp(); + virtual void repaint(); + virtual void repaintAll(); + virtual void getAbsExtents(int& x0,int& y0,int& x1,int& y1); + virtual void getClipRect(int& x0,int& y0,int& x1,int& y1); + virtual void setParent(Panel* newParent); + virtual void addChild(Panel* child); + virtual void insertChildAt(Panel* child,int index); + virtual void removeChild(Panel* child); + virtual bool wasMousePressed(MouseCode code); + virtual bool wasMouseDoublePressed(MouseCode code); + virtual bool isMouseDown(MouseCode code); + virtual bool wasMouseReleased(MouseCode code); + virtual bool wasKeyPressed(KeyCode code); + virtual bool isKeyDown(KeyCode code); + virtual bool wasKeyTyped(KeyCode code); + virtual bool wasKeyReleased(KeyCode code); + virtual void addInputSignal(InputSignal* s); + virtual void removeInputSignal(InputSignal* s); + virtual void addRepaintSignal(RepaintSignal* s); + virtual void removeRepaintSignal(RepaintSignal* s); + virtual bool isWithin(int x,int y); //in screen space + virtual Panel* isWithinTraverse(int x,int y); + virtual void localToScreen(int& x,int& y); + virtual void screenToLocal(int& x,int& y); + virtual void setCursor(Cursor* cursor); + virtual void setCursor(Scheme::SchemeCursor scu); + virtual Cursor* getCursor(); + virtual void setMinimumSize(int wide,int tall); + virtual void getMinimumSize(int& wide,int& tall); + virtual void requestFocus(); + virtual bool hasFocus(); + virtual int getChildCount(); + virtual Panel* getChild(int index); + virtual void setLayout(Layout* layout); + virtual void invalidateLayout(bool layoutNow); + virtual void setFocusNavGroup(FocusNavGroup* focusNavGroup); + virtual void requestFocusPrev(); + virtual void requestFocusNext(); + virtual void addFocusChangeSignal(FocusChangeSignal* s); + virtual bool isAutoFocusNavEnabled(); + virtual void setAutoFocusNavEnabled(bool state); + virtual void setBorder(Border* border); + virtual void setPaintBorderEnabled(bool state); + virtual void setPaintBackgroundEnabled(bool state); + virtual void setPaintEnabled(bool state); + virtual void getInset(int& left,int& top,int& right,int& bottom); + virtual void getPaintSize(int& wide,int& tall); + virtual void setPreferredSize(int wide,int tall); + virtual void getPreferredSize(int& wide,int& tall); + virtual SurfaceBase* getSurfaceBase(); + virtual bool isEnabled(); + virtual void setEnabled(bool state); + virtual void setBuildGroup(BuildGroup* buildGroup,const char* panelPersistanceName); + virtual bool isBuildGroupEnabled(); + virtual void removeAllChildren(); + virtual void repaintParent(); + virtual Panel* createPropertyPanel(); + virtual void getPersistanceText(char* buf,int bufLen); + virtual void applyPersistanceText(const char* buf); + virtual void setFgColor(Scheme::SchemeColor sc); + virtual void setBgColor(Scheme::SchemeColor sc); + virtual void setFgColor(int r,int g,int b,int a); + virtual void setBgColor(int r,int g,int b,int a); + virtual void getFgColor(int& r,int& g,int& b,int& a); + virtual void getBgColor(int& r,int& g,int& b,int& a); + virtual void setBgColor(Color color); + virtual void setFgColor(Color color); + virtual void getBgColor(Color& color); + virtual void getFgColor(Color& color); + virtual void setAsMouseCapture(bool state); + virtual void setAsMouseArena(bool state); + virtual App* getApp(); + virtual void getVirtualSize(int& wide,int& tall); + virtual void setLayoutInfo(LayoutInfo* layoutInfo); + virtual LayoutInfo* getLayoutInfo(); + virtual bool isCursorNone(); +public: //bullshit public + virtual void solveTraverse(); + virtual void paintTraverse(); + virtual void setSurfaceBaseTraverse(SurfaceBase* surfaceBase); +protected: + virtual void performLayout(); + virtual void internalPerformLayout(); + virtual void drawSetColor(Scheme::SchemeColor sc); + virtual void drawSetColor(int r,int g,int b,int a); + virtual void drawFilledRect(int x0,int y0,int x1,int y1); + virtual void drawOutlinedRect(int x0,int y0,int x1,int y1); + virtual void drawSetTextFont(Scheme::SchemeFont sf); + virtual void drawSetTextFont(Font* font); + virtual void drawSetTextColor(Scheme::SchemeColor sc); + virtual void drawSetTextColor(int r,int g,int b,int a); + virtual void drawSetTextPos(int x,int y); + virtual void drawPrintText(const char* str,int strlen); + virtual void drawPrintText(int x,int y,const char* str,int strlen); + virtual void drawPrintChar(char ch); + virtual void drawPrintChar(int x,int y,char ch); + virtual void drawSetTextureRGBA(int id,const char* rgba,int wide,int tall); + virtual void drawSetTexture(int id); + virtual void drawTexturedRect(int x0,int y0,int x1,int y1); + virtual void solve(); + virtual void paintTraverse(bool repaint); + virtual void paintBackground(); + virtual void paint(); + virtual void paintBuildOverlay(); + virtual void internalCursorMoved(int x,int y); + virtual void internalCursorEntered(); + virtual void internalCursorExited(); + virtual void internalMousePressed(MouseCode code); + virtual void internalMouseDoublePressed(MouseCode code); + virtual void internalMouseReleased(MouseCode code); + virtual void internalMouseWheeled(int delta); + virtual void internalKeyPressed(KeyCode code); + virtual void internalKeyTyped(KeyCode code); + virtual void internalKeyReleased(KeyCode code); + virtual void internalKeyFocusTicked(); + virtual void internalFocusChanged(bool lost); + virtual void internalSetCursor(); +protected: + int _pos[2]; + int _size[2]; + int _loc[2]; + int _minimumSize[2]; + int _preferredSize[2]; + Dar _childDar; + Panel* _parent; + SurfaceBase* _surfaceBase; + Dar _inputSignalDar; + Dar _repaintSignalDar; + int _clipRect[4]; + Cursor* _cursor; + Scheme::SchemeCursor _schemeCursor; + bool _visible; + Layout* _layout; + bool _needsLayout; + FocusNavGroup* _focusNavGroup; + Dar _focusChangeSignalDar; + bool _autoFocusNavEnabled; + Border* _border; +private: + bool _needsRepaint; + bool _enabled; + BuildGroup* _buildGroup; + Color _fgColor; + Color _bgColor; + LayoutInfo* _layoutInfo; + bool _paintBorderEnabled; + bool _paintBackgroundEnabled; + bool _paintEnabled; +friend class Panel; +friend class App; +friend class SurfaceBase; +friend class Image; +}; +} + +#endif diff --git a/utils/vgui/include/VGUI_PopupMenu.h b/utils/vgui/include/VGUI_PopupMenu.h new file mode 100644 index 00000000..26f6bbcd --- /dev/null +++ b/utils/vgui/include/VGUI_PopupMenu.h @@ -0,0 +1,30 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_POPUPMENU_H +#define VGUI_POPUPMENU_H + +#include +#include + +namespace vgui +{ + +class Panel; + +class VGUIAPI PopupMenu : public Menu +{ +public: + PopupMenu(int x,int y,int wide,int tall); + PopupMenu(int wide,int tall); +public: + virtual void showModal(Panel* panel); +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_ProgressBar.h b/utils/vgui/include/VGUI_ProgressBar.h new file mode 100644 index 00000000..9c3ca114 --- /dev/null +++ b/utils/vgui/include/VGUI_ProgressBar.h @@ -0,0 +1,33 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_PROGRESSBAR_H +#define VGUI_PROGRESSBAR_H + +#include +#include + +namespace vgui +{ + +class VGUIAPI ProgressBar : public Panel +{ +private: + int _segmentCount; + float _progress; +public: + ProgressBar(int segmentCount); +protected: + virtual void paintBackground(); +public: + virtual void setProgress(float progress); + virtual int getSegmentCount(); +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_RadioButton.h b/utils/vgui/include/VGUI_RadioButton.h new file mode 100644 index 00000000..89add27a --- /dev/null +++ b/utils/vgui/include/VGUI_RadioButton.h @@ -0,0 +1,29 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_RADIOBUTTON_H +#define VGUI_RADIOBUTTON_H + +#include +#include + +namespace vgui +{ + +class VGUIAPI RadioButton : public ToggleButton +{ +public: + RadioButton(const char* text,int x,int y,int wide,int tall); + RadioButton(const char* text,int x,int y); +protected: + virtual void paintBackground(); +}; + +} + +#endif + diff --git a/utils/vgui/include/VGUI_RaisedBorder.h b/utils/vgui/include/VGUI_RaisedBorder.h new file mode 100644 index 00000000..b5a35888 --- /dev/null +++ b/utils/vgui/include/VGUI_RaisedBorder.h @@ -0,0 +1,29 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_RAISEDBORDER_H +#define VGUI_RAISEDBORDER_H + +#include +#include + +namespace vgui +{ + +class Panel; + +class VGUIAPI RaisedBorder : public Border +{ +public: + RaisedBorder(); +protected: + virtual void paint(Panel* panel); +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_RepaintSignal.h b/utils/vgui/include/VGUI_RepaintSignal.h new file mode 100644 index 00000000..e728a4b4 --- /dev/null +++ b/utils/vgui/include/VGUI_RepaintSignal.h @@ -0,0 +1,25 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_REPAINTSIGNAL_H +#define VGUI_REPAINTSIGNAL_H + + + +namespace vgui +{ + +class RepaintSignal +{ +public: + virtual void panelRepainted(Panel* panel)=0; +}; + +} + + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_Scheme.h b/utils/vgui/include/VGUI_Scheme.h new file mode 100644 index 00000000..82f85001 --- /dev/null +++ b/utils/vgui/include/VGUI_Scheme.h @@ -0,0 +1,82 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_SCHEME_H +#define VGUI_SCHEME_H + +#include + + +namespace vgui +{ + +class Font; +class Cursor; + +class VGUIAPI Scheme +{ +public: + enum SchemeColor + { + sc_user=0, + sc_black, + sc_white, + sc_primary1, + sc_primary2, + sc_primary3, + sc_secondary1, + sc_secondary2, + sc_secondary3, + sc_last, + }; + enum SchemeFont + { + sf_user=0, + sf_primary1, + sf_primary2, + sf_primary3, + sf_secondary1, + sf_last, + }; + enum SchemeCursor + { + scu_user=0, + scu_none, + scu_arrow, + scu_ibeam, + scu_hourglass, + scu_crosshair, + scu_up, + scu_sizenwse, + scu_sizenesw, + scu_sizewe, + scu_sizens, + scu_sizeall, + scu_no, + scu_hand, + scu_last, + }; +public: + Scheme(); +public: + virtual void setColor(SchemeColor sc,int r,int g,int b,int a); + virtual void getColor(SchemeColor sc,int& r,int& g,int& b,int& a); + virtual void setFont(SchemeFont sf,Font* font); + virtual Font* getFont(SchemeFont sf); + virtual void setCursor(SchemeCursor sc,Cursor* cursor); + virtual Cursor* getCursor(SchemeCursor sc); +protected: + int _color[sc_last][4]; + Font* _font[sf_last]; + Cursor* _cursor[scu_last]; + friend class Panel; + friend class Canvas; +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_ScrollBar.h b/utils/vgui/include/VGUI_ScrollBar.h new file mode 100644 index 00000000..ea280ea4 --- /dev/null +++ b/utils/vgui/include/VGUI_ScrollBar.h @@ -0,0 +1,56 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_SCROLLBAR_H +#define VGUI_SCROLLBAR_H + +#include +#include +#include + +namespace vgui +{ + +class IntChangeSignal; +class Button; +class Slider; + +class VGUIAPI ScrollBar : public Panel +{ +public: + ScrollBar(int x,int y,int wide,int tall,bool vertical); +public: + virtual void setValue(int value); + virtual int getValue(); + virtual void addIntChangeSignal(IntChangeSignal* s); + virtual void setRange(int min,int max); + virtual void setRangeWindow(int rangeWindow); + virtual void setRangeWindowEnabled(bool state); + virtual void setSize(int wide,int tall); + virtual bool isVertical(); + virtual bool hasFullRange(); + virtual void setButton(Button* button,int index); + virtual Button* getButton(int index); + virtual void setSlider(Slider* slider); + virtual Slider* getSlider(); + virtual void doButtonPressed(int buttonIndex); + virtual void setButtonPressedScrollValue(int value); + virtual void validate(); +public: //bullshit public + virtual void fireIntChangeSignal(); +protected: + virtual void performLayout(); +protected: + Button* _button[2]; + Slider* _slider; + Dar _intChangeSignalDar; + int _buttonPressedScrollValue; +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_ScrollPanel.h b/utils/vgui/include/VGUI_ScrollPanel.h new file mode 100644 index 00000000..88bcf2f9 --- /dev/null +++ b/utils/vgui/include/VGUI_ScrollPanel.h @@ -0,0 +1,55 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_SCROLLPANEL_H +#define VGUI_SCROLLPANEL_H + +#include +#include + +//NOTE: You need to call validate anytime you change a scrollbar + +namespace vgui +{ + +class ScrollBar; + +class VGUIAPI ScrollPanel : public Panel +{ +private: + Panel* _clientClip; + Panel* _client; + ScrollBar* _horizontalScrollBar; + ScrollBar* _verticalScrollBar; + bool _autoVisible[2]; +public: + ScrollPanel(int x,int y,int wide,int tall); +protected: + virtual void setSize(int wide,int tall); +public: + virtual void setScrollBarVisible(bool horizontal,bool vertical); + virtual void setScrollBarAutoVisible(bool horizontal,bool vertical); + virtual Panel* getClient(); + virtual Panel* getClientClip(); + virtual void setScrollValue(int horizontal,int vertical); + virtual void getScrollValue(int& horizontal,int& vertical); + virtual void recomputeClientSize(); + virtual ScrollBar* getHorizontalScrollBar(); + virtual ScrollBar* getVerticalScrollBar(); + virtual void validate(); +public: //bullshit public + virtual void recomputeScroll(); +}; + +} + + + + + + +#endif diff --git a/utils/vgui/include/VGUI_Slider.h b/utils/vgui/include/VGUI_Slider.h new file mode 100644 index 00000000..c4c69245 --- /dev/null +++ b/utils/vgui/include/VGUI_Slider.h @@ -0,0 +1,69 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_SLIDER_H +#define VGUI_SLIDER_H + +#include +#include +#include + +namespace vgui +{ + +enum MouseCode; +class IntChangeSignal; + +class VGUIAPI Slider : public Panel +{ +private: + bool _vertical; + bool _dragging; + int _nobPos[2]; + int _nobDragStartPos[2]; + int _dragStartPos[2]; + Dar _intChangeSignalDar; + int _range[2]; + int _value; + int _rangeWindow; + bool _rangeWindowEnabled; + int _buttonOffset; +public: + Slider(int x,int y,int wide,int tall,bool vertical); +public: + virtual void setValue(int value); + virtual int getValue(); + virtual bool isVertical(); + virtual void addIntChangeSignal(IntChangeSignal* s); + virtual void setRange(int min,int max); + virtual void getRange(int& min,int& max); + virtual void setRangeWindow(int rangeWindow); + virtual void setRangeWindowEnabled(bool state); + virtual void setSize(int wide,int tall); + virtual void getNobPos(int& min, int& max); + virtual bool hasFullRange(); + virtual void setButtonOffset(int buttonOffset); +private: + virtual void recomputeNobPosFromValue(); + virtual void recomputeValueFromNobPos(); +public: //bullshit public + virtual void privateCursorMoved(int x,int y,Panel* panel); + virtual void privateMousePressed(MouseCode code,Panel* panel); + virtual void privateMouseReleased(MouseCode code,Panel* panel); +protected: + virtual void fireIntChangeSignal(); + virtual void paintBackground(); +}; + +} + +#endif + + + + + diff --git a/utils/vgui/include/VGUI_StackLayout.h b/utils/vgui/include/VGUI_StackLayout.h new file mode 100644 index 00000000..9da6652b --- /dev/null +++ b/utils/vgui/include/VGUI_StackLayout.h @@ -0,0 +1,30 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_STACKLAYOUT_H +#define VGUI_STACKLAYOUT_H + +#include +#include + +namespace vgui +{ + +class VGUIAPI StackLayout : public Layout +{ +private: + int _vgap; + bool _fitWide; +public: + StackLayout(int vgap,bool fitWide); +public: + virtual void performLayout(Panel* panel); +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_String.h b/utils/vgui/include/VGUI_String.h new file mode 100644 index 00000000..bfe9fdec --- /dev/null +++ b/utils/vgui/include/VGUI_String.h @@ -0,0 +1,61 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_STRING_H +#define VGUI_STRING_H + +#include + + +namespace vgui +{ + +class VGUIAPI String +{ + +friend class String; + +private: + + char* _text; + +public: + + String(); + String(const char* text); + String(const String& src); + +public: + + ~String(); + +private: + + int getCount(const char* text); + +public: + + int getCount(); + String operator+(String text); + String operator+(const char* text); + bool operator==(String text); + bool operator==(const char* text); + char operator[](int index); + const char* getChars(); + +public: + + static void test(); + +}; + + +} + + +#endif + diff --git a/utils/vgui/include/VGUI_Surface.h b/utils/vgui/include/VGUI_Surface.h new file mode 100644 index 00000000..7b5476af --- /dev/null +++ b/utils/vgui/include/VGUI_Surface.h @@ -0,0 +1,67 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_SURFACE_H +#define VGUI_SURFACE_H + +#include +#include +#include + +namespace vgui +{ + +class Panel; +class Cursor; + +class VGUIAPI Surface : public SurfaceBase +{ +public: + Surface(Panel* embeddedPanel); +public: + virtual void setTitle(const char* title); + virtual bool setFullscreenMode(int wide,int tall,int bpp); + virtual void setWindowedMode(); + virtual void setAsTopMost(bool state); + virtual int getModeInfoCount(); + virtual void createPopup(Panel* embeddedPanel); + virtual bool hasFocus(); + virtual bool isWithin(int x,int y); +protected: + virtual int createNewTextureID(void); + virtual void drawSetColor(int r,int g,int b,int a); + virtual void drawFilledRect(int x0,int y0,int x1,int y1); + virtual void drawOutlinedRect(int x0,int y0,int x1,int y1); + virtual void drawSetTextFont(Font* font); + virtual void drawSetTextColor(int r,int g,int b,int a); + virtual void drawSetTextPos(int x,int y); + virtual void drawPrintText(const char* text,int textLen); + virtual void drawSetTextureRGBA(int id,const char* rgba,int wide,int tall); + virtual void drawSetTexture(int id); + virtual void drawTexturedRect(int x0,int y0,int x1,int y1); + virtual void invalidate(Panel *panel); + virtual bool createPlat(); + virtual bool recreateContext(); + virtual void enableMouseCapture(bool state); + virtual void setCursor(Cursor* cursor); + virtual void swapBuffers(); + virtual void pushMakeCurrent(Panel* panel,bool useInsets); + virtual void popMakeCurrent(Panel* panel); + virtual void applyChanges(); +protected: + class SurfacePlat* _plat; + bool _needsSwap; + Panel* _embeddedPanel; + Dar _modeInfoDar; + friend class App; + friend class Panel; +}; + +} + +#endif + diff --git a/utils/vgui/include/VGUI_SurfaceBase.h b/utils/vgui/include/VGUI_SurfaceBase.h new file mode 100644 index 00000000..f654f9a4 --- /dev/null +++ b/utils/vgui/include/VGUI_SurfaceBase.h @@ -0,0 +1,81 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_SURFACEBASE_H +#define VGUI_SURFACEBASE_H + +#include +#include + +namespace vgui +{ + +class Panel; +class Cursor; +class Font; +class App; +class ImagePanel; + +class VGUIAPI SurfaceBase +{ +public: + SurfaceBase(Panel* embeddedPanel); +protected: + ~SurfaceBase(); +public: + virtual Panel* getPanel(); + virtual void requestSwap(); + virtual void resetModeInfo(); + virtual int getModeInfoCount(); + virtual bool getModeInfo(int mode,int& wide,int& tall,int& bpp); + virtual App* getApp(); + virtual void setEmulatedCursorVisible(bool state); + virtual void setEmulatedCursorPos(int x,int y); +public: + virtual void setTitle(const char* title)=0; + virtual bool setFullscreenMode(int wide,int tall,int bpp)=0; + virtual void setWindowedMode()=0; + virtual void setAsTopMost(bool state)=0; + virtual void createPopup(Panel* embeddedPanel)=0; + virtual bool hasFocus()=0; + virtual bool isWithin(int x,int y)=0; + virtual int createNewTextureID(void)=0; +protected: + virtual void addModeInfo(int wide,int tall,int bpp); +protected: + virtual void drawSetColor(int r,int g,int b,int a)=0; + virtual void drawFilledRect(int x0,int y0,int x1,int y1)=0; + virtual void drawOutlinedRect(int x0,int y0,int x1,int y1)=0; + virtual void drawSetTextFont(Font* font)=0; + virtual void drawSetTextColor(int r,int g,int b,int a)=0; + virtual void drawSetTextPos(int x,int y)=0; + virtual void drawPrintText(const char* text,int textLen)=0; + virtual void drawSetTextureRGBA(int id,const char* rgba,int wide,int tall)=0; + virtual void drawSetTexture(int id)=0; + virtual void drawTexturedRect(int x0,int y0,int x1,int y1)=0; + virtual void invalidate(Panel *panel)=0; + virtual void enableMouseCapture(bool state)=0; + virtual void setCursor(Cursor* cursor)=0; + virtual void swapBuffers()=0; + virtual void pushMakeCurrent(Panel* panel,bool useInsets)=0; + virtual void popMakeCurrent(Panel* panel)=0; + virtual void applyChanges()=0; +protected: + bool _needsSwap; + App* _app; + Panel* _embeddedPanel; + Dar _modeInfoDar; + ImagePanel* _emulatedCursor; + Cursor* _currentCursor; +friend class App; +friend class Panel; +}; + +} + +#endif + diff --git a/utils/vgui/include/VGUI_SurfaceGL.h b/utils/vgui/include/VGUI_SurfaceGL.h new file mode 100644 index 00000000..b509a12c --- /dev/null +++ b/utils/vgui/include/VGUI_SurfaceGL.h @@ -0,0 +1,98 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_SURFACEGL_H +#define VGUI_SURFACEGL_H + +//macros borrowed from GLUT to get rid of win32 dependent junk in gl headers +#ifdef _WIN32 +# ifndef APIENTRY +# define VGUI_APIENTRY_DEFINED +# if (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED) +# define APIENTRY __stdcall +# else +# define APIENTRY +# endif +# endif +# ifndef CALLBACK +# define VGUI_CALLBACK_DEFINED +# if (defined(_M_MRX000) || defined(_M_IX86) || defined(_M_ALPHA) || defined(_M_PPC)) && !defined(MIDL_PASS) +# define CALLBACK __stdcall +# else +# define CALLBACK +# endif +# endif +# ifndef WINGDIAPI +# define VGUI_WINGDIAPI_DEFINED +# define WINGDIAPI __declspec(dllimport) +# endif +# ifndef _WCHAR_T_DEFINED +typedef unsigned short wchar_t; +# define _WCHAR_T_DEFINED +# endif +# pragma comment(lib,"opengl32.lib") +#endif + +#include +#include + +#ifdef VGUI_APIENTRY_DEFINED +# undef VGUI_APIENTRY_DEFINED +# undef APIENTRY +#endif + +#ifdef VGUI_CALLBACK_DEFINED +# undef VGUI_CALLBACK_DEFINED +# undef CALLBACK +#endif + +#ifdef VGUI_WINGDIAPI_DEFINED +# undef VGUI_WINGDIAPI_DEFINED +# undef WINGDIAPI +#endif + + + +#include +#include +#include + +namespace vgui +{ + +class VGUIAPI SurfaceGL : public Surface +{ +public: + SurfaceGL(Panel* embeddedPanel); +public: + virtual void createPopup(Panel* embeddedPanel); +protected: + virtual bool recreateContext(); + virtual void pushMakeCurrent(Panel* panel,bool useInsets); + virtual void popMakeCurrent(Panel* panel); + virtual void makeCurrent(); + virtual void swapBuffers(); + virtual void setColor(int r,int g,int b); + virtual void filledRect(int x0,int y0,int x1,int y1); + virtual void outlinedRect(int x0,int y0,int x1,int y1); + virtual void setTextFont(Font* font); + virtual void setTextColor(int r,int g,int b); + virtual void setDrawPos(int x,int y); + virtual void printText(const char* str,int strlen); + virtual void setTextureRGBA(int id,const char* rgba,int wide,int tall); + virtual void setTexture(int id); + virtual void texturedRect(int x0,int y0,int x1,int y1); +protected: + int _drawPos[2]; + uchar _drawColor[3]; + uchar _drawTextColor[3]; +}; + +} + +#endif + diff --git a/utils/vgui/include/VGUI_TabPanel.h b/utils/vgui/include/VGUI_TabPanel.h new file mode 100644 index 00000000..f80bca53 --- /dev/null +++ b/utils/vgui/include/VGUI_TabPanel.h @@ -0,0 +1,49 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_TABPANEL_H +#define VGUI_TABPANEL_H + +#include +#include + +namespace vgui +{ + +class ButtonGroup; + +class VGUIAPI TabPanel : public Panel +{ +public: + enum TabPlacement + { + tp_top=0, + tp_bottom, + tp_left, + tp_right, + }; +public: + TabPanel(int x,int y,int wide,int tall); +public: + virtual Panel* addTab(const char* text); + virtual void setSelectedTab(Panel* tab); + virtual void setSize(int wide,int tall); +protected: + virtual void recomputeLayoutTop(); + virtual void recomputeLayout(); +protected: + TabPlacement _tabPlacement; + Panel* _tabArea; + Panel* _clientArea; + Panel* _selectedTab; + Panel* _selectedPanel; + ButtonGroup* _buttonGroup; +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_TablePanel.h b/utils/vgui/include/VGUI_TablePanel.h new file mode 100644 index 00000000..3a76f7a8 --- /dev/null +++ b/utils/vgui/include/VGUI_TablePanel.h @@ -0,0 +1,71 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_TABLEPANEL_H +#define VGUI_TABLEPANEL_H + +#include +#include +#include + +namespace vgui +{ + +class HeaderPanel; + +class VGUIAPI TablePanel : public Panel +{ +friend class FooVGuiTablePanelHandler; +private: + vgui::Dar _columnDar; + bool _gridVisible[2]; + int _gridWide; + int _gridTall; + int _selectedCell[2]; + int _mouseOverCell[2]; + int _editableCell[2]; + Panel* _fakeInputPanel; + bool _columnSelectionEnabled; + bool _rowSelectionEnabled; + bool _cellSelectionEnabled; + Panel* _editableCellPanel; + int _virtualSize[2]; + bool _cellEditingEnabled; +public: + TablePanel(int x,int y,int wide,int tall,int columnCount); +public: + virtual void setCellEditingEnabled(bool state); + virtual void setColumnCount(int columnCount); + virtual void setGridVisible(bool horizontal,bool vertical); + virtual void setGridSize(int gridWide,int gridTall); + virtual int getColumnCount(); + virtual void setColumnExtents(int column,int x0,int x1); + virtual void setSelectedCell(int column,int row); + virtual void getSelectedCell(int& column,int& row); + virtual void setHeaderPanel(HeaderPanel* header); + virtual void setColumnSelectionEnabled(bool state); + virtual void setRowSelectionEnabled(bool state); + virtual void setCellSectionEnabled(bool state); + virtual void setEditableCell(int column,int row); + virtual void stopCellEditing(); + virtual void getVirtualSize(int& wide,int& tall); + virtual int getRowCount()=0; + virtual int getCellTall(int row)=0; + virtual Panel* getCellRenderer(int column,int row,bool columnSelected,bool rowSelected,bool cellSelected)=0; + virtual Panel* startCellEditing(int column,int row)=0; +protected: + virtual void paint(); + virtual Panel* isWithinTraverse(int x,int y); +private: + virtual void privateMousePressed(MouseCode code,Panel* panel); + virtual void privateMouseDoublePressed(MouseCode code,Panel* panel); + virtual void privateKeyTyped(KeyCode code,Panel* panel); +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_TaskBar.h b/utils/vgui/include/VGUI_TaskBar.h new file mode 100644 index 00000000..e9ec49d9 --- /dev/null +++ b/utils/vgui/include/VGUI_TaskBar.h @@ -0,0 +1,37 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_TASKBAR_H +#define VGUI_TASKBAR_H + +#include +#include +#include + +namespace vgui +{ + +class Frame; +class Button; + +class VGUIAPI TaskBar : public Panel +{ +public: + TaskBar(int x,int y,int wide,int tall); +public: + virtual void addFrame(Frame* frame); +protected: + virtual void performLayout(); +protected: + Dar _frameDar; + Dar _taskButtonDar; + Panel* _tray; +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_TextEntry.h b/utils/vgui/include/VGUI_TextEntry.h new file mode 100644 index 00000000..682f000e --- /dev/null +++ b/utils/vgui/include/VGUI_TextEntry.h @@ -0,0 +1,80 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_TEXTENTRY_H +#define VGUI_TEXTENTRY_H + +#include +#include +#include + +namespace vgui +{ + +enum MouseCode; +enum KeyCode; +class ActionSignal; + +class VGUIAPI TextEntry : public Panel , public InputSignal +{ +public: + TextEntry(const char* text,int x,int y,int wide,int tall); +public: + virtual void setText(const char* text,int textLen); + virtual void getText(int offset,char* buf,int bufLen); + virtual void resetCursorBlink(); + virtual void doGotoLeft(); + virtual void doGotoRight(); + virtual void doGotoFirstOfLine(); + virtual void doGotoEndOfLine(); + virtual void doInsertChar(char ch); + virtual void doBackspace(); + virtual void doDelete(); + virtual void doSelectNone(); + virtual void doCopySelected(); + virtual void doPaste(); + virtual void doPasteSelected(); + virtual void doDeleteSelected(); + virtual void addActionSignal(ActionSignal* s); + virtual void setFont(Font* font); + virtual void setTextHidden(bool bHideText); +protected: + virtual void paintBackground(); + virtual void setCharAt(char ch,int index); +protected: + virtual void fireActionSignal(); + virtual bool getSelectedRange(int& cx0,int& cx1); + virtual bool getSelectedPixelRange(int& cx0,int& cx1); + virtual int cursorToPixelSpace(int cursorPos); + virtual void selectCheck(); +protected: //InputSignal + virtual void cursorMoved(int x,int y,Panel* panel); + virtual void cursorEntered(Panel* panel); + virtual void cursorExited(Panel* panel); + virtual void mousePressed(MouseCode code,Panel* panel); + virtual void mouseDoublePressed(MouseCode code,Panel* panel); + virtual void mouseReleased(MouseCode code,Panel* panel); + virtual void mouseWheeled(int delta,Panel* panel); + virtual void keyPressed(KeyCode code,Panel* panel); + virtual void keyTyped(KeyCode code,Panel* panel); + virtual void keyReleased(KeyCode code,Panel* panel); + virtual void keyFocusTicked(Panel* panel); +protected: + Dar _lineDar; + int _cursorPos; + bool _cursorBlink; + bool _hideText; + long _cursorNextBlinkTime; + int _cursorBlinkRate; + int _select[2]; + Dar _actionSignalDar; + Font* _font; +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_TextGrid.h b/utils/vgui/include/VGUI_TextGrid.h new file mode 100644 index 00000000..beb7e527 --- /dev/null +++ b/utils/vgui/include/VGUI_TextGrid.h @@ -0,0 +1,42 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_TEXTGRID_H +#define VGUI_TEXTGRID_H + +#include +#include +#include + +namespace vgui +{ + +class VGUIAPI TextGrid : public Panel +{ +public: + TextGrid(int gridWide,int gridTall,int x,int y,int wide,int tall); +public: + virtual void setGridSize(int wide,int tall); + virtual void newLine(); + virtual void setXY(int x,int y); + //virtual void setBgColor(int r,int g,int b); + //virtual void setFgColor(int r,int g,int b); + virtual int vprintf(const char* format,va_list argList); + virtual int printf(const char* format,...); +protected: + virtual void paintBackground(); +protected: + int _xy[2]; + int _bgColor[3]; + int _fgColor[3]; + char* _grid; //[_gridSize[0]*_gridSize[1]*7] ch,br,bg,bb,fr,fg,fb + int _gridSize[2]; +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_TextImage.h b/utils/vgui/include/VGUI_TextImage.h new file mode 100644 index 00000000..b11feaf2 --- /dev/null +++ b/utils/vgui/include/VGUI_TextImage.h @@ -0,0 +1,58 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_TEXTIMAGE_H +#define VGUI_TEXTIMAGE_H + +#include +#include +#include + + +//TODO: need to add wrapping flag instead of being arbitrary about when wrapping and auto-resizing actually happens +// This is probably why you are having problems if you had text in a constructor and then changed the font + +namespace vgui +{ + +class Panel; +class Font; +class App; + +class VGUIAPI TextImage : public Image +{ +private: + char* _text; + int _textBufferLen; + vgui::Scheme::SchemeFont _schemeFont; + vgui::Font* _font; + int _textColor[4]; + vgui::Scheme::SchemeColor _textSchemeColor; +public: + TextImage(int textBufferLen,const char* text); + TextImage(const char* text); +private: + virtual void init(int textBufferLen,const char* text); +public: + virtual void getTextSize(int& wide,int& tall); + virtual void getTextSizeWrapped(int& wide,int& tall); + virtual Font* getFont(); + virtual void setText(int textBufferLen,const char* text); + virtual void setText(const char* text); + virtual void setFont(vgui::Scheme::SchemeFont schemeFont); + virtual void setFont(vgui::Font* font); + virtual void setSize(int wide,int tall); +protected: + virtual void paint(Panel* panel); +}; + +} + +#endif + + + diff --git a/utils/vgui/include/VGUI_TextPanel.h b/utils/vgui/include/VGUI_TextPanel.h new file mode 100644 index 00000000..b000f7bb --- /dev/null +++ b/utils/vgui/include/VGUI_TextPanel.h @@ -0,0 +1,46 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_TEXTPANEL_H +#define VGUI_TEXTPANEL_H + +#include +#include +#include + +//NOTE : If you are having trouble with this class, your problem is probably in TextImage + +namespace vgui +{ + +class TextImage; +class Font; + +class VGUIAPI TextPanel : public Panel +{ +private: + TextImage* _textImage; +public: + TextPanel(const char* text,int x,int y,int wide,int tall); +public: + virtual void setText(const char* text); + virtual void setFont(vgui::Scheme::SchemeFont schemeFont); + virtual void setFont(vgui::Font* font); + virtual void setSize(int wide,int tall); + virtual void setFgColor(int r,int g,int b,int a); + virtual void setFgColor(Scheme::SchemeColor sc); + virtual TextImage* getTextImage(); +protected: + virtual void paint(); +}; + +} + +#endif + + + diff --git a/utils/vgui/include/VGUI_TickSignal.h b/utils/vgui/include/VGUI_TickSignal.h new file mode 100644 index 00000000..bb0bcd52 --- /dev/null +++ b/utils/vgui/include/VGUI_TickSignal.h @@ -0,0 +1,22 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_TICKSIGNAL_H +#define VGUI_TICKSIGNAL_H + +#include + +namespace vgui +{ +class VGUIAPI TickSignal + { + public: + virtual void ticked()=0; + }; +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_ToggleButton.h b/utils/vgui/include/VGUI_ToggleButton.h new file mode 100644 index 00000000..0e6d8bc1 --- /dev/null +++ b/utils/vgui/include/VGUI_ToggleButton.h @@ -0,0 +1,26 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_TOGGLEBUTTON_H +#define VGUI_TOGGLEBUTTON_H + +#include +#include + +namespace vgui +{ + +class VGUIAPI ToggleButton : public Button +{ +public: + ToggleButton(const char* text,int x,int y,int wide,int tall); + ToggleButton(const char* text,int x,int y); +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_TreeFolder.h b/utils/vgui/include/VGUI_TreeFolder.h new file mode 100644 index 00000000..ab86cda6 --- /dev/null +++ b/utils/vgui/include/VGUI_TreeFolder.h @@ -0,0 +1,36 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_TREEFOLDER_H +#define VGUI_TREEFOLDER_H + +#include +#include + +namespace vgui +{ + +class VGUIAPI TreeFolder : public Panel +{ +public: + TreeFolder(const char* name); + TreeFolder(const char* name,int x,int y); +protected: + virtual void init(const char* name); +public: + virtual void setOpenedTraverse(bool state); + virtual void setOpened(bool state); + virtual bool isOpened(); +protected: + virtual void paintBackground(); +protected: + bool _opened; +}; + +} + +#endif \ No newline at end of file diff --git a/utils/vgui/include/VGUI_WizardPanel.h b/utils/vgui/include/VGUI_WizardPanel.h new file mode 100644 index 00000000..d2f7a2be --- /dev/null +++ b/utils/vgui/include/VGUI_WizardPanel.h @@ -0,0 +1,146 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_WIZARDPANEL_H +#define VGUI_WIZARDPANEL_H + +#include +#include + +namespace vgui +{ + +class ActionSignal; + +class VGUIAPI WizardPanel : public Panel +{ + +public: + + class VGUIAPI WizardPage : public Panel + { + + friend class WizardPanel; + + private: + + WizardPage* _backWizardPage; + WizardPage* _nextWizardPage; + bool _backButtonEnabled; + bool _nextButtonEnabled; + bool _finishedButtonEnabled; + bool _cancelButtonEnabled; + bool _backButtonVisible; + bool _nextButtonVisible; + bool _finishedButtonVisible; + bool _cancelButtonVisible; + char* _backButtonText; + char* _nextButtonText; + char* _finishedButtonText; + char* _cancelButtonText; + Dar _switchingToBackPageSignalDar; + Dar _switchingToNextPageSignalDar; + char* _title; + Panel* _wantedFocus; + + private: + + virtual void fireSwitchingToBackPageSignals(); + virtual void fireSwitchingToNextPageSignals(); + virtual void init(); + + public: + + WizardPage(); + WizardPage(int wide,int tall); + + public: + + virtual void setBackWizardPage(WizardPage* backWizardPage); + virtual void setNextWizardPage(WizardPage* nextWizardPage); + virtual WizardPage* getBackWizardPage(); + virtual WizardPage* getNextWizardPage(); + + virtual bool isBackButtonEnabled(); + virtual bool isNextButtonEnabled(); + virtual bool isFinishedButtonEnabled(); + virtual bool isCancelButtonEnabled(); + virtual void setBackButtonEnabled(bool state); + virtual void setNextButtonEnabled(bool state); + virtual void setFinishedButtonEnabled(bool state); + virtual void setCancelButtonEnabled(bool state); + + virtual bool isBackButtonVisible(); + virtual bool isNextButtonVisible(); + virtual bool isFinishedButtonVisible(); + virtual bool isCancelButtonVisible(); + virtual void setBackButtonVisible(bool state); + virtual void setNextButtonVisible(bool state); + virtual void setFinishedButtonVisible(bool state); + virtual void setCancelButtonVisible(bool state); + + virtual void getBackButtonText(char* text,int textLen); + virtual void getNextButtonText(char* text,int textLen); + virtual void getFinishedButtonText(char* text,int textLen); + virtual void getCancelButtonText(char* text,int textLen); + virtual void setBackButtonText(const char* text); + virtual void setNextButtonText(const char* text); + virtual void setFinishedButtonText(const char* text); + virtual void setCancelButtonText(const char* text); + + virtual void setWantedFocus(Panel* panel); + virtual Panel* getWantedFocus(); + + virtual void addSwitchingToBackPageSignal(ActionSignal* s); + virtual void addSwitchingToNextPageSignal(ActionSignal* s); + + virtual void setTitle(const char* title); + virtual void getTitle(char* buf,int bufLen); + + }; + +private: + + Button* _backButton; + Button* _nextButton; + Button* _finishedButton; + Button* _cancelButton; + WizardPage* _currentWizardPage; + Dar _pageChangedActionSignalDar; + +private: + + virtual void fireFinishedActionSignal(); + virtual void fireCancelledActionSignal(); + virtual void firePageChangedActionSignal(); + +protected: + + virtual void performLayout(); + +public: + + WizardPanel(int x,int y,int wide,int tall); + +public: + + virtual void setCurrentWizardPage(WizardPage* currentWizardPage); + virtual void addFinishedActionSignal(ActionSignal* s); + virtual void addCancelledActionSignal(ActionSignal* s); + virtual void addPageChangedActionSignal(ActionSignal* s); + virtual void doBack(); + virtual void doNext(); + virtual void getCurrentWizardPageTitle(char* buf,int bufLen); + virtual WizardPage* getCurrentWizardPage(); + +}; + +} + + +#endif + diff --git a/utils/vgui/lib/win32_vc6/vgui.lib b/utils/vgui/lib/win32_vc6/vgui.lib new file mode 100644 index 00000000..aff77160 Binary files /dev/null and b/utils/vgui/lib/win32_vc6/vgui.lib differ diff --git a/xash.dsw b/xash.dsw index 8f2e2e60..0351bebd 100644 --- a/xash.dsw +++ b/xash.dsw @@ -39,18 +39,6 @@ Package=<4> ############################################################################### -Project: "utils"=".\utils\utils.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - Project: "engine"=".\engine\engine.dsp" - Package Owner=<4> Package=<5> @@ -87,18 +75,6 @@ Package=<4> ############################################################################### -Project: "snd_dx"=".\snd_dx\snd_dx.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - Global: Package=<5>