21 Nov 2010

This commit is contained in:
g-cont 2010-11-21 00:00:00 +03:00 committed by Alibek Omarov
parent 857a547f01
commit 15138ca306
138 changed files with 5391 additions and 2363 deletions

View File

@ -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\

View File

@ -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

View File

@ -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!

View File

@ -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;

View File

@ -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" );
}
/*

View File

@ -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
//

View File

@ -4,6 +4,7 @@
//=======================================================================
#include <dsound.h>
#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 )

View File

@ -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 )

View File

@ -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();

View File

@ -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" );

View File

@ -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 );

View File

@ -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;

View File

@ -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 )
{

View File

@ -3,6 +3,7 @@
// s_utils.c - common sound functions
//=======================================================================
#include "common.h"
#include "sound.h"
// hardcoded macros to test for zero crossing

View File

@ -3,6 +3,7 @@
// s_vox.c - npc sentences
//=======================================================================
#include "common.h"
#include "sound.h"
#include "const.h"

View File

@ -6,14 +6,6 @@
#ifndef SOUND_H
#define SOUND_H
#include <windows.h>
#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

View File

@ -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 );
}

View File

@ -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

View File

@ -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

View File

@ -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();

View File

@ -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"

View File

@ -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];

View File

@ -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

View File

@ -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

View File

@ -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 ));

View File

@ -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;
}

View File

@ -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 );

View File

@ -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" );

View File

@ -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;
}

View File

@ -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"

View File

@ -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

View File

@ -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( &section, 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, &section, 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;
}

View File

@ -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

View File

@ -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;
}

View File

@ -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;

503
launch/tools/conv_image.c Normal file
View File

@ -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;
}

View File

@ -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

View File

@ -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");

View File

@ -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

View File

@ -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 );

View File

@ -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;
}

View File

@ -9,17 +9,11 @@
#include <windows.h>
#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;

View File

@ -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 );
}

View File

@ -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

View File

@ -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!

View File

@ -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;
}

View File

@ -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

View File

@ -1,702 +0,0 @@
//=======================================================================
// Copyright XashXT Group 2008 ©
// conv_doom.c - convert doom1\2 resources
//=======================================================================
#include "ripper.h"
#include <sys/stat.h>
#include <stdio.h>
// 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;
}

View File

@ -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;
}

View File

@ -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 );
}

View File

@ -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

107
utils/vgui/include/VGUI.h Normal file
View File

@ -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

View File

@ -0,0 +1,84 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_ACTIONSIGNAL_H
#define VGUI_ACTIONSIGNAL_H
#include<VGUI.h>
/*
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<ActionSignalSimple*>(signal);
if(ss!=null)
{
ss->actionPerformed(this);
}
ActionSignalCommand* si=dynamic_cast<ActionSignalInt*>(signal);
if(si!=null)
{
si->actionPerformed(_intValue,this);
}
}
}
*/
#include<VGUI.h>
namespace vgui
{
class Panel;
class VGUIAPI ActionSignal
{
public:
virtual void actionPerformed(Panel* panel)=0;
};
}
#endif

View File

@ -0,0 +1,132 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_APP_H
#define VGUI_APP_H
#include<VGUI.h>
#include<VGUI_MouseCode.h>
#include<VGUI_KeyCode.h>
#include<VGUI_Dar.h>
#include<VGUI_Cursor.h>
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<SurfaceBase*> _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<TickSignal*> _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

View File

@ -0,0 +1,37 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_BITMAP_H
#define VGUI_BITMAP_H
#include<VGUI.h>
#include<VGUI_Image.h>
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

View File

@ -0,0 +1,29 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_BITMAPTGA_H
#define VGUI_BITMAPTGA_H
#include<VGUI_Bitmap.h>
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

View File

@ -0,0 +1,45 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_BORDER_H
#define VGUI_BORDER_H
#include<VGUI.h>
#include<VGUI_Image.h>
//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

View File

@ -0,0 +1,46 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_BORDERLAYOUT_H
#define VGUI_BORDERLAYOUT_H
#include<VGUI.h>
#include<VGUI_Layout.h>
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

View File

@ -0,0 +1,33 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_BORDERPAIR_H
#define VGUI_BORDERPAIR_H
#include<VGUI.h>
#include<VGUI_Border.h>
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

View File

@ -0,0 +1,67 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_BUILDGROUP_H
#define VGUI_BUILDGROUP_H
#include<VGUI.h>
#include<VGUI_Dar.h>
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<ChangeSignal*> _currentPanelChangeSignalDar;
Dar<Panel*> _panelDar;
Dar<char*> _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

View File

@ -0,0 +1,61 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_BUTTON_H
#define VGUI_BUTTON_H
#include<VGUI.h>
#include<VGUI_Label.h>
#include<VGUI_Dar.h>
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<ActionSignal*> _actionSignalDar;
int _mouseClickMask;
ButtonGroup* _buttonGroup;
ButtonController* _buttonController;
};
}
#endif

View File

@ -0,0 +1,27 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_BUTTONCONTROLLER_H
#define VGUI_BUTTONCONTROLLER_H
#include<VGUI.h>
namespace vgui
{
class Button;
class VGUIAPI ButtonController
{
public:
virtual void addSignals(Button* button)=0;
virtual void removeSignals(Button* button)=0;
};
}
#endif

View File

@ -0,0 +1,30 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_BUTTONGROUP_H
#define VGUI_BUTTONGROUP_H
#include<VGUI.h>
#include<VGUI_Dar.h>
namespace vgui
{
class Button;
class VGUIAPI ButtonGroup
{
public:
virtual void addButton(Button* button);
virtual void setSelected(Button* button);
protected:
Dar<Button*> _buttonDar;
};
}
#endif

View File

@ -0,0 +1,26 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_CHANGESIGNAL_H
#define VGUI_CHANGESIGNAL_H
#include<VGUI.h>
namespace vgui
{
class Panel;
class VGUIAPI ChangeSignal
{
public:
virtual void valueChanged(Panel* panel)=0;
};
}
#endif

View File

@ -0,0 +1,28 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_CHECKBUTTON_H
#define VGUI_CHECKBUTTON_H
#include<VGUI.h>
#include<VGUI_ToggleButton.h>
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

View File

@ -0,0 +1,44 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_COLOR_H
#define VGUI_COLOR_H
#include<VGUI.h>
#include<VGUI_Scheme.h>
//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

View File

@ -0,0 +1,34 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_COMBOKEY_H
#define VGUI_COMBOKEY_H
#include<VGUI.h>
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

View File

@ -0,0 +1,40 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_CONFIGWIZARD_H
#define VGUI_CONFIGWIZARD_H
#include<VGUI.h>
#include<VGUI_Panel.h>
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

View File

@ -0,0 +1,57 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_CURSOR_H
#define VGUI_CURSOR_H
#include<VGUI.h>
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

View File

@ -0,0 +1,193 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_DAR_H
#define VGUI_DAR_H
#include<stdlib.h>
#include<string.h>
#include<VGUI.h>
namespace vgui
{
//Simple lightweight dynamic array implementation
template<class ELEMTYPE> 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<wantedCapacity){newCapacity*=2;}
//allocate and zero newData
ELEMTYPE* newData=new ELEMTYPE[newCapacity];
if(newData==null){exit(0);return;}
memset(newData,0,sizeof(ELEMTYPE)*newCapacity);
_capacity=newCapacity;
//copy data into newData
for(int i=0;i<_count;i++){newData[i]=_data[i];}
delete[] _data;
_data=newData;
}
void setCount(int count)
{
if((count<0)||(count>_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<char>;
template class VGUIAPI Dar<char*>;
template class VGUIAPI Dar<int>;
template class VGUIAPI Dar<class Button*>;
template class VGUIAPI Dar<class SurfaceBase*>;
template class VGUIAPI Dar<class InputSignal*>;
template class VGUIAPI Dar<class FocusChangeSignal*>;
template class VGUIAPI Dar<class FrameSignal*>;
template class VGUIAPI Dar<class ActionSignal*>;
template class VGUIAPI Dar<class IntChangeSignal*>;
template class VGUIAPI Dar<class TickSignal*>;
template class VGUIAPI Dar<class Dar<char>*>;
template class VGUIAPI Dar<class Frame*>;
template class VGUIAPI Dar<class DesktopIcon*>;
template class VGUIAPI Dar<class ChangeSignal*>;
template class VGUIAPI Dar<class Panel*>;
template class VGUIAPI Dar<class Label*>;
template class VGUIAPI Dar<class RepaintSignal*>;
}
#endif

View File

@ -0,0 +1,49 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_DATAINPUTSTREAM_H
#define VGUI_DATAINPUTSTREAM_H
#include<VGUI.h>
#include<VGUI_InputStream.h>
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

View File

@ -0,0 +1,42 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_DESKTOP_H
#define VGUI_DESKTOP_H
#include<VGUI.h>
#include<VGUI_Dar.h>
#include<VGUI_Panel.h>
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<DesktopIcon*> _desktopIconDar;
int _cascade[2];
};
}
#endif

View File

@ -0,0 +1,41 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_DESKTOPICON_H
#define VGUI_DESKTOPICON_H
#include<VGUI.h>
#include<VGUI_Panel.h>
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

View File

@ -0,0 +1,65 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_EDITPANEL_H
#define VGUI_EDITPANEL_H
#include<VGUI.h>
#include<VGUI_Panel.h>
#include<VGUI_Dar.h>
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<char>* getLine(int lineIndex);
virtual void setChar(Dar<char>* lineDar,int x,char ch,char fill);
virtual void setChar(Dar<char>* lineDar,int x,char ch);
virtual void shiftLineLeft(Dar<char>* lineDar,int x,int count);
virtual void shiftLineRight(Dar<char>* lineDar,int x,int count);
private:
virtual int spatialCharOffsetBetweenTwoLines(Dar<char>* srcDar,Dar<char>* dstDar,int x);
protected:
Dar<Dar<char>*> _lineDarDar;
int _cursor[2];
bool _cursorBlink;
int _cursorNextBlinkTime;
Font* _font;
};
}
#endif

View File

@ -0,0 +1,29 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_ETCHEDBORDER_H
#define VGUI_ETCHEDBORDER_H
#include<VGUI.h>
#include<VGUI_Border.h>
namespace vgui
{
class Panel;
class VGUIAPI EtchedBorder : public Border
{
public:
EtchedBorder();
protected:
virtual void paint(Panel* panel);
};
}
#endif

View File

@ -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<stdio.h>
#include<VGUI_InputStream.h>
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

View File

@ -0,0 +1,29 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_FLOWLAYOUT_H
#define VGUI_FLOWLAYOUT_H
#include<VGUI.h>
#include<VGUI_Layout.h>
namespace vgui
{
class VGUIAPI FlowLayout : public Layout
{
private:
int _hgap;
public:
FlowLayout(int hgap);
public:
virtual void performLayout(Panel* panel);
};
}
#endif

View File

@ -0,0 +1,26 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_FOCUSCHANGESIGNAL_H
#define VGUI_FOCUSCHANGESIGNAL_H
#include<VGUI.h>
namespace vgui
{
class Panel;
class VGUIAPI FocusChangeSignal
{
public:
virtual void focusChanged(bool lost,Panel* panel)=0;
};
}
#endif

View File

@ -0,0 +1,35 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_FOCUSNAVGROUP_H
#define VGUI_FOCUSNAVGROUP_H
#include<VGUI.h>
#include<VGUI_Dar.h>
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<Panel*> _panelDar;
int _currentIndex;
friend class Panel;
};
}
#endif

View File

@ -0,0 +1,48 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_FONT_H
#define VGUI_FONT_H
#include<VGUI.h>
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

View File

@ -0,0 +1,73 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_FRAME_H
#define VGUI_FRAME_H
#include<VGUI.h>
#include<VGUI_Panel.h>
#include<VGUI_Dar.h>
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<FrameSignal*> _frameSignalDar;
Frame* _resizeable;
};
}
#endif

View File

@ -0,0 +1,27 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_FRAMESIGNAL_H
#define VGUI_FRAMESIGNAL_H
#include<VGUI.h>
namespace vgui
{
class Frame;
class VGUIAPI FrameSignal
{
public:
virtual void closing(Frame* frame)=0;
virtual void minimizing(Frame* frame,bool toTray)=0;
};
}
#endif

View File

@ -0,0 +1,30 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_GRIDLAYOUT_H
#define VGUI_GRIDLAYOUT_H
#include<VGUI.h>
#include<VGUI_Layout.h>
namespace vgui
{
/*
class VGUIAPI GridLayout : public Layout
{
public:
GridLayout(int rows,int cols,int hgap,int vgap);
protected:
int _rows;
int _cols;
};
*/
}
#endif

View File

@ -0,0 +1,65 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_HEADERPANEL_H
#define VGUI_HEADERPANEL_H
#include<VGUI.h>
#include<VGUI_Panel.h>
#include<VGUI_Dar.h>
#include<VGUI_Cursor.h>
namespace vgui
{
enum MouseCode;
class ChangeSignal;
class VGUIAPI HeaderPanel : public Panel
{
private:
Dar<Panel*> _sliderPanelDar;
Dar<Panel*> _sectionPanelDar;
Dar<ChangeSignal*> _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

View File

@ -0,0 +1,62 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_IMAGE_H
#define VGUI_IMAGE_H
#include<VGUI.h>
#include<VGUI_Scheme.h>
#include<VGUI_Color.h>
//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

View File

@ -0,0 +1,38 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_IMAGEPANEL_H
#define VGUI_IMAGEPANEL_H
#include<VGUI.h>
#include<VGUI_Panel.h>
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

View File

@ -0,0 +1,39 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_INPUTSIGNAL_H
#define VGUI_INPUTSIGNAL_H
#include<VGUI.h>
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

View File

@ -0,0 +1,30 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_FILE_H
#define VGUI_FILE_H
#include<VGUI.h>
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

View File

@ -0,0 +1,26 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_INTCHANGESIGNAL_H
#define VGUI_INTCHANGESIGNAL_H
#include<VGUI.h>
namespace vgui
{
class Panel;
class VGUIAPI IntChangeSignal
{
public:
virtual void intChanged(int value,Panel* panel)=0;
};
}
#endif

View File

@ -0,0 +1,35 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_INTLABEL_H
#define VGUI_INTLABEL_H
#include<VGUI.h>
#include<VGUI_Label.h>
#include<VGUI_IntChangeSignal.h>
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

View File

@ -0,0 +1,126 @@
//========= Copyright Š 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_KEYCODE_H
#define VGUI_KEYCODE_H
#include<VGUI.h>
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

View File

@ -0,0 +1,80 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_LABEL_H
#define VGUI_LABEL_H
#include<VGUI.h>
#include<VGUI_Panel.h>
#include<VGUI_Scheme.h>
//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

View File

@ -0,0 +1,31 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_LAYOUT_H
#define VGUI_LAYOUT_H
#include<VGUI.h>
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

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