Original Source for 1.13 Mod High Resolution version from 12/06/05

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@21 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
lalien
2006-04-19 11:32:51 +00:00
commit e54aeb96aa
790 changed files with 741287 additions and 0 deletions
+360
View File
@@ -0,0 +1,360 @@
#ifdef PRECOMPILEDHEADERS
#include "Utils All.h"
#else
#include "types.h"
#include "Animated ProgressBar.h"
#include "MemMan.h"
#include "debug.h"
#include "Font Control.h"
#include "vsurface.h"
#include "video.h"
#include "Render Dirty.h"
#include "music control.h"
#endif
double rStart, rEnd;
double rActual;
#define MAX_PROGRESSBARS 4
PROGRESSBAR *pBar[ MAX_PROGRESSBARS ];
BOOLEAN gfUseLoadScreenProgressBar = FALSE;
UINT16 gusLeftmostShaded = 0;
extern BOOLEAN bShowSmallImage;
void CreateLoadingScreenProgressBar()
{
gusLeftmostShaded = 162;
gfUseLoadScreenProgressBar = TRUE;
// Special case -> show small image centered
if (bShowSmallImage == TRUE)
{
if (iResolution > 0)
{
CreateProgressBar(0, iScreenWidthOffset + 162, iScreenHeightOffset + 427, iScreenWidthOffset + 480, iScreenHeightOffset + 443);
}
}
else
{
if (iResolution == 0)
{
CreateProgressBar(0, 162, 427, 480, 443);
}
else if (iResolution == 1)
{
CreateProgressBar(0, 202, 533, 600, 554);
}
else if (iResolution == 2)
{
CreateProgressBar(0, 259, 683, 767, 708);
}
}
}
void RemoveLoadingScreenProgressBar()
{
gfUseLoadScreenProgressBar = FALSE;
RemoveProgressBar( 0 );
SetFontShadow(DEFAULT_SHADOW);
}
//This creates a single progress bar given the coordinates without a panel (containing a title and background).
//A panel is automatically created if you specify a title using SetProgressBarTitle
BOOLEAN CreateProgressBar( UINT8 ubProgressBarID, UINT16 usLeft, UINT16 usTop, UINT16 usRight, UINT16 usBottom )
{
PROGRESSBAR *pNew;
//Allocate new progress bar
pNew = (PROGRESSBAR*)MemAlloc( sizeof( PROGRESSBAR ) );
Assert( pNew );
if( pBar[ ubProgressBarID ] )
RemoveProgressBar( ubProgressBarID );
memset( pNew, 0, sizeof( PROGRESSBAR ) );
pBar[ ubProgressBarID ] = pNew;
pNew->ubProgressBarID = ubProgressBarID;
//Assign coordinates
pNew->usBarLeft = usLeft;
pNew->usBarTop = usTop;
pNew->usBarRight = usRight;
pNew->usBarBottom = usBottom;
//Init default data
pNew->fPanel = FALSE;
pNew->usMsgFont = (UINT16)FONT12POINT1;
pNew->ubMsgFontForeColor = FONT_BLACK;
pNew->ubMsgFontShadowColor = 0;
SetRelativeStartAndEndPercentage( pNew->ubProgressBarID, 0, 100, NULL );
pNew->swzTitle = NULL;
//Default the progress bar's color to be red
pNew->ubColorFillRed = 150;
pNew->ubColorFillGreen = 0;
pNew->ubColorFillBlue = 0;
pNew->fDisplayText = FALSE;
return TRUE;
}
//You may also define a panel to go in behind the progress bar. You can now assign a title to go with
//the panel.
void DefineProgressBarPanel( UINT32 ubID, UINT8 r, UINT8 g, UINT8 b,
UINT16 usLeft, UINT16 usTop, UINT16 usRight, UINT16 usBottom )
{
PROGRESSBAR *pCurr;
Assert( ubID < MAX_PROGRESSBARS );
pCurr = pBar[ ubID ];
if( !pCurr )
return;
pCurr->fPanel = TRUE;
pCurr->usPanelLeft = usLeft;
pCurr->usPanelTop = usTop;
pCurr->usPanelRight = usRight;
pCurr->usPanelBottom = usBottom;
pCurr->usColor = Get16BPPColor( FROMRGB( r, g, b ) );
//Calculate the slightly lighter and darker versions of the same rgb color
pCurr->usLtColor = Get16BPPColor( FROMRGB( (UINT8)min( 255, (UINT16)(r*1.33)),
(UINT8)min( 255, (UINT16)(g*1.33)),
(UINT8)min( 255, (UINT16)(b*1.33)) ));
pCurr->usDkColor = Get16BPPColor( FROMRGB( (UINT8)(r*0.75), (UINT8)(g*0.75), (UINT8)(b*0.75) ) );
}
//Assigning a title for the panel will automatically position the text horizontally centered on the
//panel and vertically centered from the top of the panel, to the top of the progress bar.
void SetProgressBarTitle( UINT32 ubID, UINT16 *pString, UINT32 usFont, UINT8 ubForeColor, UINT8 ubShadowColor )
{
PROGRESSBAR *pCurr;
Assert( ubID < MAX_PROGRESSBARS );
pCurr = pBar[ ubID ];
if( !pCurr )
return;
if( pCurr->swzTitle )
{
MemFree( pCurr->swzTitle );
pCurr->swzTitle = NULL;
}
if( pString && wcslen( pString ) )
{
pCurr->swzTitle = (UINT16*)MemAlloc( sizeof( UINT16 ) * ( wcslen( pString ) + 1 ) );
swprintf( pCurr->swzTitle, pString );
}
pCurr->usTitleFont = (UINT16)usFont;
pCurr->ubTitleFontForeColor = ubForeColor;
pCurr->ubTitleFontShadowColor = ubShadowColor;
}
//Unless you set up the attributes, any text you pass to SetRelativeStartAndEndPercentage will
//default to FONT12POINT1 in a black color.
void SetProgressBarMsgAttributes( UINT32 ubID, UINT32 usFont, UINT8 ubForeColor, UINT8 ubShadowColor )
{
PROGRESSBAR *pCurr;
Assert( ubID < MAX_PROGRESSBARS );
pCurr = pBar[ ubID ];
if( !pCurr )
return;
pCurr->usMsgFont = (UINT16)usFont;
pCurr->ubMsgFontForeColor = ubForeColor;
pCurr->ubMsgFontShadowColor = ubShadowColor;
}
//When finished, the progress bar needs to be removed.
void RemoveProgressBar( UINT8 ubID )
{
Assert( ubID < MAX_PROGRESSBARS );
if( pBar[ubID] )
{
if( pBar[ubID]->swzTitle )
MemFree( pBar[ubID]->swzTitle );
MemFree( pBar[ubID] );
pBar[ubID] = NULL;
return;
}
}
//An important setup function. The best explanation is through example. The example being the loading
//of a file -- there are many stages of the map loading. In JA2, the first step is to load the tileset.
//Because it is a large chunk of the total loading of the map, we may gauge that it takes up 30% of the
//total load. Because it is also at the beginning, we would pass in the arguments ( 0, 30, "text" ).
//As the process animates using UpdateProgressBar( 0 to 100 ), the total progress bar will only reach 30%
//at the 100% mark within UpdateProgressBar. At that time, you would go onto the next step, resetting the
//relative start and end percentage from 30 to whatever, until your done.
void SetRelativeStartAndEndPercentage( UINT8 ubID, UINT32 uiRelStartPerc, UINT32 uiRelEndPerc, UINT16 *str)
{
PROGRESSBAR *pCurr;
UINT16 usStartX, usStartY;
Assert( ubID < MAX_PROGRESSBARS );
pCurr = pBar[ ubID ];
if( !pCurr )
return;
pCurr->rStart = uiRelStartPerc*0.01;
pCurr->rEnd = uiRelEndPerc*0.01;
//Render the entire panel now, as it doesn't need update during the normal rendering
if( pCurr->fPanel )
{
//Draw panel
ColorFillVideoSurfaceArea( FRAME_BUFFER,
pCurr->usPanelLeft, pCurr->usPanelTop, pCurr->usPanelRight, pCurr->usPanelBottom, pCurr->usLtColor );
ColorFillVideoSurfaceArea( FRAME_BUFFER,
pCurr->usPanelLeft+1, pCurr->usPanelTop+1, pCurr->usPanelRight, pCurr->usPanelBottom, pCurr->usDkColor );
ColorFillVideoSurfaceArea( FRAME_BUFFER,
pCurr->usPanelLeft+1, pCurr->usPanelTop+1, pCurr->usPanelRight-1, pCurr->usPanelBottom-1, pCurr->usColor );
InvalidateRegion( pCurr->usPanelLeft, pCurr->usPanelTop, pCurr->usPanelRight, pCurr->usPanelBottom );
//Draw title
if( pCurr->swzTitle )
{
usStartX = pCurr->usPanelLeft + // left position
(pCurr->usPanelRight - pCurr->usPanelLeft)/2 - // + half width
StringPixLength( pCurr->swzTitle, pCurr->usTitleFont ) / 2; // - half string width
usStartY = pCurr->usPanelTop + 3;
SetFont( pCurr->usTitleFont );
SetFontForeground( pCurr->ubTitleFontForeColor );
SetFontShadow( pCurr->ubTitleFontShadowColor );
SetFontBackground( 0 );
mprintf( usStartX, usStartY, pCurr->swzTitle );
}
}
if( pCurr->fDisplayText )
{
//Draw message
if( str )
{
if( pCurr->fUseSaveBuffer )
{
UINT16 usFontHeight = GetFontHeight( pCurr->usMsgFont );
RestoreExternBackgroundRect( pCurr->usBarLeft, pCurr->usBarBottom, (INT16)(pCurr->usBarRight-pCurr->usBarLeft), (INT16)(usFontHeight + 3) );
}
SetFont( pCurr->usMsgFont );
SetFontForeground( pCurr->ubMsgFontForeColor );
SetFontShadow( pCurr->ubMsgFontShadowColor );
SetFontBackground( 0 );
mprintf( pCurr->usBarLeft, pCurr->usBarBottom + 3, str );
}
}
}
//This part renders the progress bar at the percentage level that you specify. If you have set relative
//percentage values in the above function, then the uiPercentage will be reflected based off of the relative
//percentages.
void RenderProgressBar( UINT8 ubID, UINT32 uiPercentage )
{
static UINT32 uiLastTime = 0;
UINT32 uiCurTime = GetJA2Clock();
double rActual;
PROGRESSBAR *pCurr=NULL;
//UINT32 r, g;
INT32 end;
Assert( ubID < MAX_PROGRESSBARS );
pCurr = pBar[ubID];
if( pCurr == NULL )
return;
if( pCurr )
{
rActual = pCurr->rStart+(pCurr->rEnd-pCurr->rStart)*uiPercentage*0.01;
if( rActual - pCurr->rLastActual < 0.01 )
{
return;
}
pCurr->rLastActual = ( DOUBLE )( ( INT32)( rActual * 100 ) * 0.01 );
end = (INT32)(pCurr->usBarLeft+2.0+rActual*(pCurr->usBarRight-pCurr->usBarLeft-4));
if( end < pCurr->usBarLeft+2 || end > pCurr->usBarRight-2 )
{
return;
}
if( gfUseLoadScreenProgressBar )
{
ColorFillVideoSurfaceArea( FRAME_BUFFER,
pCurr->usBarLeft, pCurr->usBarTop, end, pCurr->usBarBottom,
Get16BPPColor(FROMRGB( pCurr->ubColorFillRed, pCurr->ubColorFillGreen, pCurr->ubColorFillBlue )) );
//if( pCurr->usBarRight > gusLeftmostShaded )
//{
// ShadowVideoSurfaceRect( FRAME_BUFFER, gusLeftmostShaded+1, pCurr->usBarTop, end, pCurr->usBarBottom );
// gusLeftmostShaded = (UINT16)end;
//}
}
else
{
//Border edge of the progress bar itself in gray
ColorFillVideoSurfaceArea( FRAME_BUFFER,
pCurr->usBarLeft, pCurr->usBarTop, pCurr->usBarRight, pCurr->usBarBottom,
Get16BPPColor(FROMRGB(160, 160, 160)) );
//Interior of progress bar in black
ColorFillVideoSurfaceArea( FRAME_BUFFER,
pCurr->usBarLeft+2, pCurr->usBarTop+2, pCurr->usBarRight-2, pCurr->usBarBottom-2,
Get16BPPColor(FROMRGB( 0, 0, 0)) );
ColorFillVideoSurfaceArea(FRAME_BUFFER, pCurr->usBarLeft+2, pCurr->usBarTop+2, end, pCurr->usBarBottom-2, Get16BPPColor(FROMRGB(72 , 155, 24)));
}
InvalidateRegion( pCurr->usBarLeft, pCurr->usBarTop, pCurr->usBarRight, pCurr->usBarBottom );
ExecuteBaseDirtyRectQueue();
EndFrameBufferRender();
RefreshScreen( NULL );
}
// update music here
if( uiCurTime > ( uiLastTime + 200 ) )
{
MusicPoll( TRUE );
uiLastTime = GetJA2Clock();
}
}
void SetProgressBarColor( UINT8 ubID, UINT8 ubColorFillRed, UINT8 ubColorFillGreen, UINT8 ubColorFillBlue )
{
PROGRESSBAR *pCurr=NULL;
Assert( ubID < MAX_PROGRESSBARS );
pCurr = pBar[ubID];
if( pCurr == NULL )
return;
pCurr->ubColorFillRed = ubColorFillRed;
pCurr->ubColorFillGreen = ubColorFillGreen;
pCurr->ubColorFillBlue = ubColorFillBlue;
}
void SetProgressBarTextDisplayFlag( UINT8 ubID, BOOLEAN fDisplayText, BOOLEAN fUseSaveBuffer, BOOLEAN fSaveScreenToFrameBuffer )
{
PROGRESSBAR *pCurr=NULL;
Assert( ubID < MAX_PROGRESSBARS );
pCurr = pBar[ubID];
if( pCurr == NULL )
return;
pCurr->fDisplayText = fDisplayText;
pCurr->fUseSaveBuffer = fUseSaveBuffer;
//if we are to use the save buffer, blit the portion of the screen to the save buffer
if( fSaveScreenToFrameBuffer )
{
UINT16 usFontHeight = GetFontHeight( pCurr->usMsgFont )+3;
//blit everything to the save buffer ( cause the save buffer can bleed through )
BlitBufferToBuffer(guiRENDERBUFFER, guiSAVEBUFFER, pCurr->usBarLeft, pCurr->usBarBottom, (UINT16)(pCurr->usBarRight-pCurr->usBarLeft), usFontHeight );
}
}
+78
View File
@@ -0,0 +1,78 @@
#ifndef __ANIMATED_PROGRESSBAR_H
#define __ANIMATED_PROGRESSBAR_H
#include "types.h"
#define MAX_PROGRESSBARS 4
typedef struct PROGRESSBAR
{
UINT8 ubProgressBarID;
UINT16 usBarLeft, usBarTop, usBarRight, usBarBottom;
BOOLEAN fPanel;
UINT16 usPanelLeft, usPanelTop, usPanelRight, usPanelBottom;
UINT16 usColor, usLtColor, usDkColor;
UINT16 *swzTitle;
UINT16 usTitleFont;
UINT8 ubTitleFontForeColor, ubTitleFontShadowColor;
UINT16 usMsgFont;
UINT8 ubMsgFontForeColor, ubMsgFontShadowColor;
UINT8 ubRelativeStartPercentage, ubRelativeEndPercentage;
UINT8 ubColorFillRed;
UINT8 ubColorFillGreen;
UINT8 ubColorFillBlue;
double rStart, rEnd;
BOOLEAN fDisplayText;
BOOLEAN fUseSaveBuffer; //use the save buffer when display the text
double rLastActual;
}PROGRESSBAR;
extern PROGRESSBAR *pBar[ MAX_PROGRESSBARS ];
void CreateLoadingScreenProgressBar();
void RemoveLoadingScreenProgressBar();
//This creates a single progress bar given the coordinates without a panel (containing a title and background).
//A panel is automatically created if you specify a title using SetProgressBarTitle
BOOLEAN CreateProgressBar( UINT8 ubProgressBarID, UINT16 usLeft, UINT16 usTop, UINT16 usRight, UINT16 usBottom );
//You may also define a panel to go in behind the progress bar. You can now assign a title to go with
//the panel.
void DefineProgressBarPanel( UINT32 ubID, UINT8 r, UINT8 g, UINT8 b,
UINT16 usLeft, UINT16 usTop, UINT16 usRight, UINT16 usBottom );
//Assigning a title for the panel will automatically position the text horizontally centered on the
//panel and vertically centered from the top of the panel, to the top of the progress bar.
void SetProgressBarTitle( UINT32 ubID, UINT16 *pString, UINT32 usFont, UINT8 ubForeColor, UINT8 ubShadowColor );
//Unless you set up the attributes, any text you pass to SetRelativeStartAndEndPercentage will
//default to FONT12POINT1 in a black color.
void SetProgressBarMsgAttributes( UINT32 ubID, UINT32 usFont, UINT8 ubForeColor, UINT8 ubShadowColor );
//When finished, the progress bar needs to be removed.
void RemoveProgressBar( UINT8 ubID );
//An important setup function. The best explanation is through example. The example being the loading
//of a file -- there are many stages of the map loading. In JA2, the first step is to load the tileset.
//Because it is a large chunk of the total loading of the map, we may gauge that it takes up 30% of the
//total load. Because it is also at the beginning, we would pass in the arguments ( 0, 30, "text" ).
//As the process animates using UpdateProgressBar( 0 to 100 ), the total progress bar will only reach 30%
//at the 100% mark within UpdateProgressBar. At that time, you would go onto the next step, resetting the
//relative start and end percentage from 30 to whatever, until your done.
void SetRelativeStartAndEndPercentage( UINT8 ubID, UINT32 uiRelStartPerc, UINT32 uiRelEndPerc, UINT16 *str);
//This part renders the progress bar at the percentage level that you specify. If you have set relative
//percentage values in the above function, then the uiPercentage will be reflected based off of the relative
//percentages.
void RenderProgressBar( UINT8 ubID, UINT32 uiPercentage );
//Sets the color of the progress bars main color.
void SetProgressBarColor( UINT8 ubID, UINT8 ubColorFillRed, UINT8 ubColorFillGreen, UINT8 ubColorFillBlue );
//Pass in TRUE to display the strings.
void SetProgressBarTextDisplayFlag( UINT8 ubID, BOOLEAN fDisplayText, BOOLEAN fUseSaveBuffer, BOOLEAN fSaveScreenToFrameBuffer );
#endif
+306
View File
@@ -0,0 +1,306 @@
//----------------------------------------------------------------------------------
// Cinematics Module
//
//
// Stolen from Nemesis by Derek Beland.
// Originally by Derek Beland and Bret Rowden.
//
//----------------------------------------------------------------------------------
//#include "LocalCodeAll.h"
#include "Types.h"
#include <stdio.h>
#include <io.h>
#include <string.h>
#include <fcntl.h>
#include <share.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <malloc.h>
#include <stdlib.h>
#include "DEBUG.H"
#include "FileMan.h"
#include "smack.h"
#include "ddraw.h"
#include "mss.h"
#include "DirectX Common.h"
#include "DirectDraw Calls.h"
#include "Cinematics.h"
#include "soundman.h"
#ifdef JA2
#include "video.h"
#else
#include "video2.h"
#endif
#include "vsurface_private.h"
#include "Intro.h"
#include "radmalw.i"
#include <crtdbg.h>
//-Structures----------------------------------------------------------------------
//-Flags-and-Symbols---------------------------------------------------------------
#define SMK_NUM_FLICS 4 // Maximum number of flics open
// SMKFLIC uiFlags
#define SMK_FLIC_OPEN 0x00000001 // Flic is open
#define SMK_FLIC_PLAYING 0x00000002 // Flic is playing
#define SMK_FLIC_LOOP 0x00000004 // Play flic in a loop
#define SMK_FLIC_AUTOCLOSE 0x00000008 // Close when done
//-Globals-------------------------------------------------------------------------
SMKFLIC SmkList[SMK_NUM_FLICS];
HWND hDisplayWindow=0;
UINT32 uiDisplayHeight, uiDisplayWidth;
BOOLEAN fSuspendFlics=FALSE;
UINT32 uiFlicsPlaying=0;
UINT32 guiSmackPixelFormat=SMACKBUFFER565;
LPDIRECTDRAWSURFACE lpVideoPlayback=NULL;
LPDIRECTDRAWSURFACE2 lpVideoPlayback2=NULL;
//-Function-Prototypes-------------------------------------------------------------
void SmkInitialize(HWND hWindow, UINT32 uiWidth, UINT32 uiHeight);
void SmkShutdown(void);
SMKFLIC *SmkPlayFlic(CHAR8 *cFilename, UINT32 uiLeft, UINT32 uiTop, BOOLEAN fAutoClose);
BOOLEAN SmkPollFlics(void);
SMKFLIC *SmkOpenFlic(CHAR8 *cFilename);
void SmkSetBlitPosition(SMKFLIC *pSmack, UINT32 uiLeft, UINT32 uiTop);
void SmkCloseFlic(SMKFLIC *pSmack);
SMKFLIC *SmkGetFreeFlic(void);
void SmkSetupVideo(void);
void SmkShutdownVideo(void);
BOOLEAN SmkPollFlics(void)
{
UINT32 uiCount;
BOOLEAN fFlicStatus=FALSE;
DDSURFACEDESC SurfaceDescription;
for(uiCount=0; uiCount < SMK_NUM_FLICS; uiCount++)
{
if(SmkList[uiCount].uiFlags & SMK_FLIC_PLAYING)
{
fFlicStatus=TRUE;
if(!fSuspendFlics)
{
if(!SmackWait(SmkList[uiCount].SmackHandle))
{
DDLockSurface(SmkList[uiCount].lpDDS, NULL, &SurfaceDescription, 0, NULL);
SmackToBuffer(SmkList[uiCount].SmackHandle,SmkList[uiCount].uiLeft,
SmkList[uiCount].uiTop,
SurfaceDescription.lPitch,
SmkList[uiCount].SmackHandle->Height,
SurfaceDescription.lpSurface,
guiSmackPixelFormat);
SmackDoFrame(SmkList[uiCount].SmackHandle);
DDUnlockSurface(SmkList[uiCount].lpDDS, SurfaceDescription.lpSurface);
// temp til I figure out what to do with it
//InvalidateRegion(0,0, 640, 480, FALSE);
// Check to see if the flic is done the last frame
if(SmkList[uiCount].SmackHandle->FrameNum==(SmkList[uiCount].SmackHandle->Frames-1))
{
// If flic is looping, reset frame to 0
if(SmkList[uiCount].uiFlags & SMK_FLIC_LOOP)
SmackGoto(SmkList[uiCount].SmackHandle, 0);
else if(SmkList[uiCount].uiFlags & SMK_FLIC_AUTOCLOSE)
SmkCloseFlic(&SmkList[uiCount]);
}
else
SmackNextFrame(SmkList[uiCount].SmackHandle);
}
}
}
}
if(!fFlicStatus)
SmkShutdownVideo();
return(fFlicStatus);
}
void SmkInitialize(HWND hWindow, UINT32 uiWidth, UINT32 uiHeight)
{
HDIGDRIVER pSoundDriver = NULL;
// Wipe the flic list clean
memset(SmkList, 0, sizeof(SMKFLIC)*SMK_NUM_FLICS);
// Set playback window properties
hDisplayWindow=hWindow;
uiDisplayWidth=uiWidth;
uiDisplayHeight=uiHeight;
// Use MMX acceleration, if available
SmackUseMMX(1);
//Get the sound Driver handle
pSoundDriver = SoundGetDriverHandle();
//if we got the sound handle, use sound during the intro
if( pSoundDriver )
SmackSoundUseMSS( pSoundDriver );
}
void SmkShutdown(void)
{
UINT32 uiCount;
// Close and deallocate any open flics
for(uiCount=0; uiCount < SMK_NUM_FLICS; uiCount++)
{
if(SmkList[uiCount].uiFlags & SMK_FLIC_OPEN)
SmkCloseFlic(&SmkList[uiCount]);
}
}
SMKFLIC *SmkPlayFlic(CHAR8 *cFilename, UINT32 uiLeft, UINT32 uiTop, BOOLEAN fClose)
{
SMKFLIC *pSmack;
// Open the flic
if((pSmack=SmkOpenFlic(cFilename))==NULL)
return(NULL);
// Set the blitting position on the screen
SmkSetBlitPosition(pSmack, uiLeft, uiTop);
// We're now playing, flag the flic for the poller to update
pSmack->uiFlags|=SMK_FLIC_PLAYING;
if(fClose)
pSmack->uiFlags|=SMK_FLIC_AUTOCLOSE;
return(pSmack);
}
SMKFLIC *SmkOpenFlic(CHAR8 *cFilename)
{
SMKFLIC *pSmack;
HANDLE hFile;
// Get an available flic slot from the list
if(!(pSmack=SmkGetFreeFlic()))
{
ErrorMsg("SMK ERROR: Out of flic slots, cannot open another");
return(NULL);
}
// Attempt opening the filename
if(!(pSmack->hFileHandle=FileOpen(cFilename, FILE_OPEN_EXISTING | FILE_ACCESS_READ, FALSE)))
{
ErrorMsg("SMK ERROR: Can't open the SMK file");
return(NULL);
}
//Get the real file handle for the file man handle for the smacker file
hFile = GetRealFileHandleFromFileManFileHandle( pSmack->hFileHandle );
// Allocate a Smacker buffer for video decompression
if(!(pSmack->SmackBuffer=SmackBufferOpen(hDisplayWindow,SMACKAUTOBLIT,SCREEN_WIDTH,SCREEN_HEIGHT,0,0)))
{
ErrorMsg("SMK ERROR: Can't allocate a Smacker decompression buffer");
return(NULL);
}
if(!(pSmack->SmackHandle=SmackOpen((CHAR8 *)hFile, SMACKFILEHANDLE | SMACKTRACKS, SMACKAUTOEXTRA)))
// if(!(pSmack->SmackHandle=SmackOpen(cFilename, SMACKTRACKS, SMACKAUTOEXTRA)))
{
ErrorMsg("SMK ERROR: Smacker won't open the SMK file");
return(NULL);
}
// Make sure we have a video surface
SmkSetupVideo();
pSmack->cFilename=cFilename;
pSmack->lpDDS=lpVideoPlayback2;
pSmack->hWindow=hDisplayWindow;
// Smack flic is now open and ready to go
pSmack->uiFlags|=SMK_FLIC_OPEN;
return(pSmack);
}
void SmkSetBlitPosition(SMKFLIC *pSmack, UINT32 uiLeft, UINT32 uiTop)
{
pSmack->uiLeft=uiLeft;
pSmack->uiTop=uiTop;
}
void SmkCloseFlic(SMKFLIC *pSmack)
{
// Attempt opening the filename
FileClose(pSmack->hFileHandle);
// Deallocate the smack buffers
SmackBufferClose(pSmack->SmackBuffer);
// Close the smack flic
SmackClose(pSmack->SmackHandle);
// Zero the memory, flags, etc.
memset(pSmack, 0, sizeof(SMKFLIC));
}
SMKFLIC *SmkGetFreeFlic(void)
{
UINT32 uiCount;
for(uiCount=0; uiCount < SMK_NUM_FLICS; uiCount++)
if(!(SmkList[uiCount].uiFlags & SMK_FLIC_OPEN))
return(&SmkList[uiCount]);
return(NULL);
}
void SmkSetupVideo(void)
{
DDSURFACEDESC SurfaceDescription;
HRESULT ReturnCode;
UINT16 usRed, usGreen, usBlue;
HVSURFACE hVSurface;
// DEF:
// lpVideoPlayback2=CinematicModeOn();
GetVideoSurface( &hVSurface, FRAME_BUFFER );
lpVideoPlayback2 = GetVideoSurfaceDDSurface( hVSurface );
ZEROMEM(SurfaceDescription);
SurfaceDescription.dwSize = sizeof (DDSURFACEDESC);
ReturnCode = IDirectDrawSurface2_GetSurfaceDesc ( lpVideoPlayback2, &SurfaceDescription );
if (ReturnCode != DD_OK)
{
DirectXAttempt ( ReturnCode, __LINE__, __FILE__ );
return;
}
usRed = (UINT16) SurfaceDescription.ddpfPixelFormat.dwRBitMask;
usGreen = (UINT16) SurfaceDescription.ddpfPixelFormat.dwGBitMask;
usBlue = (UINT16) SurfaceDescription.ddpfPixelFormat.dwBBitMask;
if((usRed==0xf800) && (usGreen==0x07e0) && (usBlue==0x001f))
guiSmackPixelFormat=SMACKBUFFER565;
else
guiSmackPixelFormat=SMACKBUFFER555;
}
void SmkShutdownVideo(void)
{
//DEF:
// CinematicModeOff();
}
+65
View File
@@ -0,0 +1,65 @@
#ifndef _CINEMATICS_H_
#define _CINEMATICS_H_
#include "smack.h"
typedef struct {
CHAR8 *cFilename;
// HFILE hFileHandle;
HWFILE hFileHandle;
Smack *SmackHandle;
SmackBuf *SmackBuffer;
UINT32 uiFlags;
LPDIRECTDRAWSURFACE2 lpDDS;
HWND hWindow;
UINT32 uiFrame;
UINT32 uiLeft, uiTop;
// LPDIRECTDRAW2 lpDD;
// UINT32 uiNumFrames;
// UINT8 *pAudioData;
// UINT8 *pCueData;
} SMKFLIC;
void SmkInitialize(HWND hWindow, UINT32 uiWidth, UINT32 uiHeight);
void SmkShutdown(void);
SMKFLIC *SmkPlayFlic(CHAR8 *cFilename, UINT32 uiLeft, UINT32 uiTop, BOOLEAN fAutoClose);
BOOLEAN SmkPollFlics(void);
SMKFLIC *SmkOpenFlic(CHAR8 *cFilename);
void SmkSetBlitPosition(SMKFLIC *pSmack, UINT32 uiLeft, UINT32 uiTop);
void SmkCloseFlic(SMKFLIC *pSmack);
SMKFLIC *SmkGetFreeFlic(void);
/*
//--------------------------------------------------------------------------
// Prototypes etc. for our functions that make use of the Smacker library.
//
// Written by Derek Beland, Jan 11, 1995
#define FLICSOUNDID "BLAH" // ID for smack flic w/ sound :)
typedef struct {
unsigned long offset;
unsigned long length;
} SMPLARRAY;
extern SmackBuf *sbuf;
extern Smack *smk;
extern int smktag;
extern HANDLE smkhandle;
extern int SmackFlicIsOpened;
extern int SmackFlicIsPlaying;
HANDLE OpenSmackFlic(char *fname,Smack **s,u32);
int GetNextCue(void);
void PlayCueSamples(void);
void InitFlicSamples(HANDLE fhandle);
void FreeFlicSamples(void);
int SmackPlayFlic(char *,u32);
void SmackShowNextFrame(void);
void CloseSmackFlic(void);
void InitPal(HWND wh);
*/
#endif
+1632
View File
File diff suppressed because it is too large Load Diff
+255
View File
@@ -0,0 +1,255 @@
#ifndef __CURSORS_H
#define __CURSORS_H
// INDIVIDUAL CURSORS
typedef enum
{
CURSOR_NORMAL,
CURSOR_TARGET,
CURSOR_TARGETON1,
CURSOR_TARGETON2,
CURSOR_TARGETON3,
CURSOR_TARGETON4,
CURSOR_TARGETON5,
CURSOR_TARGETON6,
CURSOR_TARGETON7,
CURSOR_TARGETON8,
CURSOR_TARGETON9,
CURSOR_TARGETW1,
CURSOR_TARGETW2,
CURSOR_TARGETW3,
CURSOR_TARGETW4,
CURSOR_TARGETW5,
CURSOR_TARGETRED,
CURSOR_TARGETBLACK,
CURSOR_TARGETDKBLACK,
CURSOR_TARGETBURSTCONFIRM,
CURSOR_TARGETBURST,
CURSOR_TARGETBURSTRED,
CURSOR_TARGETBURSTDKBLACK,
CURSOR_PUNCHGRAY,
CURSOR_PUNCHRED,
CURSOR_PUNCHRED_ON1,
CURSOR_PUNCHRED_ON2,
CURSOR_PUNCHYELLOW_ON1,
CURSOR_PUNCHYELLOW_ON2,
CURSOR_PUNCHNOGO_ON1,
CURSOR_PUNCHNOGO_ON2,
CURSOR_RUN1,
CURSOR_WALK1,
CURSOR_SWAT1,
CURSOR_PRONE1,
CURSOR_HANDGRAB,
CURSOR_NORMGRAB,
CURSOR_KNIFE_REG,
CURSOR_KNIFE_HIT,
CURSOR_KNIFE_HIT_ON1,
CURSOR_KNIFE_HIT_ON2,
CURSOR_KNIFE_YELLOW_ON1,
CURSOR_KNIFE_YELLOW_ON2,
CURSOR_KNIFE_NOGO_ON1,
CURSOR_KNIFE_NOGO_ON2,
CURSOR_CROSS_REG,
CURSOR_CROSS_ACTIVE,
CURSOR_WWW,
CURSOR_LAPTOP_SCREEN,
CURSOR_IBEAM,
CURSOR_LOOK,
CURSOR_TALK,
CURSOR_BLACKTALK,
CURSOR_REDTALK,
CURSOR_EXIT_NORTH,
CURSOR_EXIT_SOUTH,
CURSOR_EXIT_EAST,
CURSOR_EXIT_WEST,
CURSOR_NOEXIT_NORTH,
CURSOR_NOEXIT_SOUTH,
CURSOR_NOEXIT_EAST,
CURSOR_NOEXIT_WEST,
CURSOR_CONEXIT_NORTH,
CURSOR_CONEXIT_SOUTH,
CURSOR_CONEXIT_EAST,
CURSOR_CONEXIT_WEST,
CURSOR_STRATEGIC_VEHICLE,
CURSOR_STRATEGIC_FOOT,
CURSOR_INVALID_ACTION,
CURSOR_CHOPPER,
CURSOR_FLASH_TARGET,
CURSOR_FLASH_TARGETBURST,
CURSOR_FLASH_TALK,
CURSOR_FLASH_REDTALK,
CURSOR_CHECKMARK,
CURSOR_TARGETWR1,
CURSOR_TARGETYELLOW1,
CURSOR_TARGETYELLOW2,
CURSOR_TARGETYELLOW3,
CURSOR_TARGETYELLOW4,
CURSOR_EXIT_GRID,
CURSOR_NOEXIT_GRID,
CURSOR_CONEXIT_GRID,
CURSOR_GOOD_WIRECUT,
CURSOR_BAD_WIRECUT,
CURSOR_GOOD_RELOAD,
CURSOR_BAD_RELOAD,
CUROSR_IBEAM_WHITE,
CURSOR_GOOD_THROW,
CURSOR_BAD_THROW,
CURSOR_RED_THROW,
CURSOR_FLASH_THROW,
CURSOR_THROWKON1,
CURSOR_THROWKON2,
CURSOR_THROWKON3,
CURSOR_THROWKON4,
CURSOR_THROWKON5,
CURSOR_THROWKON6,
CURSOR_THROWKON7,
CURSOR_THROWKON8,
CURSOR_THROWKON9,
CURSOR_THROWKW1,
CURSOR_THROWKW2,
CURSOR_THROWKW3,
CURSOR_THROWKW4,
CURSOR_THROWKW5,
CURSOR_THROWKWR1,
CURSOR_THROWKYELLOW1,
CURSOR_THROWKYELLOW2,
CURSOR_THROWKYELLOW3,
CURSOR_THROWKYELLOW4,
CURSOR_ITEM_GOOD_THROW,
CURSOR_ITEM_BAD_THROW,
CURSOR_ITEM_RED_THROW,
CURSOR_ITEM_FLASH_THROW,
CURSOR_ITEM_GIVE,
CURSOR_BOMB_GRAY,
CURSOR_BOMB_RED,
CURSOR_REMOTE_GRAY,
CURSOR_REMOTE_RED,
CURSOR_ENTERV,
CURSOR_DRIVEV,
CURSOR_WAIT,
CURSOR_PLACEMERC,
CURSOR_PLACEGROUP,
CURSOR_DPLACEMERC,
CURSOR_DPLACEGROUP,
CURSOR_REPAIR,
CURSOR_REPAIRRED,
CURSOR_JAR,
CURSOR_JARRED,
CURSOR_CAN,
CURSOR_CANRED,
CURSOR_X,
CURSOR_WAIT_NODELAY,
CURSOR_EXCHANGE_PLACES,
CURSOR_STRATEGIC_BULLSEYE,
CURSOR_JUMP_OVER,
CURSOR_FUEL,
CURSOR_FUEL_RED,
} CursorTypeDefines;
typedef enum
{
C_MISC,
C_ACTIONMODE,
C_ACTIONMODERED,
C_ACTIONMODEBLACK,
C_TARGMODEBURST,
C_TARGMODEBURSTRED,
C_TARGMODEBURSTBLACK,
C_TRINGS,
C_TWRINGS,
C_BLACKTARGET,
C_PUNCHGRAY,
C_PUNCHRED,
C_RUN1,
C_WALK1,
C_SWAT1,
C_PRONE1,
C_GRAB1,
C_GRAB2,
C_KNIFE1,
C_KNIFE2,
C_CROSS1,
C_CROSS2,
C_WWW,
C_LAPTOPSCREEN,
C_IBEAM,
C_LOOK,
C_TALK,
C_BLACKTALK,
C_REDTALK,
C_EXITARROWS,
C_STRATVEH,
C_STRATFOOT,
C_INVALIDACTION,
C_CHOPPER,
C_CHECKMARK,
C_YELLOWRINGS,
C_WIRECUT,
C_WIRECUTR,
C_RELOAD,
C_RELOADR,
C_IBEAM_WHITE,
C_THROWG,
C_THROWB,
C_THROWR,
C_ITEMTHROW,
C_BOMB_GREY,
C_BOMB_RED,
C_REMOTE_GREY,
C_REMOTE_RED,
C_ENTERV,
C_MOVEV,
C_WAIT,
C_PLACEMERC,
C_PLACEGROUP,
C_DPLACEMERC,
C_DPLACEGROUP,
C_REPAIR,
C_REPAIRR,
C_JAR,
C_JARRED,
C_X,
C_CAN,
C_CANRED,
C_EXCHANGE,
C_BULLSEYE,
C_JUMPOVER,
C_FUEL,
C_FUEL_RED,
NUM_CURSOR_FILES
} CursorSurfaceDefines;
#define MOUSE_LEVEL_GROUND 0
#define MOUSE_LEVEL_ROOF 1
void RaiseMouseToLevel( INT8 bLevel );
void InitCursors( );
void HandleAnimatedCursors( );
void DrawMouseActionPoints( );
void UpdateAnimatedCursorFrames( UINT32 uiCursorIndex );
void SyncPairedCursorFrames( UINT32 uiSrcCursor, UINT32 uiDestCursor );
void SetCursorSpecialFrame( UINT32 uiCursor, UINT8 ubFrame );
void SetCursorFlags( UINT32 uiCursor, UINT8 ubFlags );
void RemoveCursorFlags( UINT32 uiCursor, UINT8 ubFlags );
#endif
+69
View File
@@ -0,0 +1,69 @@
#ifdef PRECOMPILEDHEADERS
#include "Utils All.h"
#else
#include "types.h"
#include "Debug Control.h"
#include "stdio.h"
#endif
#ifdef _ANIMSUBSYSTEM_DEBUG
void AnimDbgMessage( CHAR8 *strMessage)
{
FILE *OutFile;
if ((OutFile = fopen("AnimDebug.txt", "a+t")) != NULL)
{
fprintf(OutFile, "%s\n", strMessage);
fclose(OutFile);
}
}
#endif
#ifdef _PHYSICSSUBSYSTEM_DEBUG
void PhysicsDbgMessage( CHAR8 *strMessage)
{
FILE *OutFile;
if ((OutFile = fopen("PhysicsDebug.txt", "a+t")) != NULL)
{
fprintf(OutFile, "%s\n", strMessage);
fclose(OutFile);
}
}
#endif
#ifdef _AISUBSYSTEM_DEBUG
void AiDbgMessage( CHAR8 *strMessage)
{
FILE *OutFile;
if ((OutFile = fopen("AiDebug.txt", "a+t")) != NULL)
{
fprintf(OutFile, "%s\n", strMessage);
fclose(OutFile);
}
}
#endif
void LiveMessage( CHAR8 *strMessage)
{
FILE *OutFile;
if ((OutFile = fopen("Log.txt", "a+t")) != NULL)
{
fprintf(OutFile, "%s\n", strMessage);
fclose(OutFile);
}
}
+57
View File
@@ -0,0 +1,57 @@
#ifndef __DEBUG_CONTROL_
#define __DEBUG_CONTROL_
#include "types.h"
//#define _PHYSICSSUBSYSTEM_DEBUG
//#define _AISUBSYSTEM_DEBUG
#ifdef JA2BETAVERSION
// #define _ANIMSUBSYSTEM_DEBUG
#endif
void LiveMessage( CHAR8 *strMessage);
#ifdef _ANIMSUBSYSTEM_DEBUG
#define AnimDebugMsg(c) AnimDbgMessage( (c) )
extern void AnimDbgMessage( CHAR8 *Str);
#else
#define AnimDebugMsg(c)
#endif
#ifdef _PHYSICSSUBSYSTEM_DEBUG
#define PhysicsDebugMsg(c) PhysicsDbgMessage( (c) )
extern void PhysicsDbgMessage( CHAR8 *Str);
#else
#define PhysicsDebugMsg(c)
#endif
#ifdef _AISUBSYSTEM_DEBUG
#define AiDebugMsg(c) AiDbgMessage( (c) )
extern void AiDbgMessage( CHAR8 *Str);
#else
#define AiDebugMsg(c)
#endif
#endif
+73
View File
@@ -0,0 +1,73 @@
#ifdef PRECOMPILEDHEADERS
#include "Utils All.h"
#else
#include "Encrypted File.h"
#include "FileMan.h"
#include "Debug.h"
#endif
#include "Language Defines.h"
BOOLEAN LoadEncryptedDataFromFile(STR pFileName, STR16 pDestString, UINT32 uiSeekFrom, UINT32 uiSeekAmount)
{
HWFILE hFile;
UINT16 i;
UINT32 uiBytesRead;
hFile = FileOpen(pFileName, FILE_ACCESS_READ, FALSE);
if ( !hFile )
{
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "LoadEncryptedDataFromFile: Failed to FileOpen");
return( FALSE );
}
if ( FileSeek( hFile, uiSeekFrom, FILE_SEEK_FROM_START ) == FALSE )
{
FileClose(hFile);
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "LoadEncryptedDataFromFile: Failed FileSeek");
return( FALSE );
}
if( !FileRead( hFile, pDestString, uiSeekAmount, &uiBytesRead) )
{
FileClose(hFile);
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "LoadEncryptedDataFromFile: Failed FileRead");
return( FALSE );
}
// Decrement, by 1, any value > 32
for(i=0; (i<uiSeekAmount) && (pDestString[i] != 0); i++ )
{
if( pDestString[i] > 33 )
pDestString[i] -= 1;
#ifdef POLISH
switch( pDestString[ i ] )
{
case 260: pDestString[ i ] = 165; break;
case 262: pDestString[ i ] = 198; break;
case 280: pDestString[ i ] = 202; break;
case 321: pDestString[ i ] = 163; break;
case 323: pDestString[ i ] = 209; break;
case 211: pDestString[ i ] = 211; break;
case 346: pDestString[ i ] = 338; break;
case 379: pDestString[ i ] = 175; break;
case 377: pDestString[ i ] = 143; break;
case 261: pDestString[ i ] = 185; break;
case 263: pDestString[ i ] = 230; break;
case 281: pDestString[ i ] = 234; break;
case 322: pDestString[ i ] = 179; break;
case 324: pDestString[ i ] = 241; break;
case 243: pDestString[ i ] = 243; break;
case 347: pDestString[ i ] = 339; break;
case 380: pDestString[ i ] = 191; break;
case 378: pDestString[ i ] = 376; break;
}
#endif
}
FileClose(hFile);
return(TRUE);
}
+8
View File
@@ -0,0 +1,8 @@
#ifndef __ENCRYPTED_H_
#define __ENCRYPTED_H_
#include "types.h"
BOOLEAN LoadEncryptedDataFromFile(STR pFileName, STR16 pDestString, UINT32 uiSeekFrom, UINT32 uiSeekAmount);
#endif
+239
View File
@@ -0,0 +1,239 @@
#ifdef PRECOMPILEDHEADERS
#include "Utils All.h"
#else
#include <stdio.h>
#include <stdarg.h>
#include <time.h>
#include "sgp.h"
#include "container.h"
#include "wcheck.h"
#include "Event Manager.h"
#include "Timer Control.h"
#endif
HLIST hEventQueue = NULL;
HLIST hDelayEventQueue = NULL;
HLIST hDemandEventQueue = NULL;
#define QUEUE_RESIZE 20
// LOCAL FUNCTIONS
HLIST GetQueue( UINT8 ubQueueID );
void SetQueue( UINT8 ubQueueID, HLIST hQueue );
BOOLEAN InitializeEventManager( )
{
// Create Queue
hEventQueue = CreateList( QUEUE_RESIZE, sizeof( PTR ) );
if ( hEventQueue == NULL )
{
return( FALSE );
}
// Create Delay Queue
hDelayEventQueue = CreateList( QUEUE_RESIZE, sizeof( PTR ) );
if ( hDelayEventQueue == NULL )
{
return( FALSE );
}
// Create Demand Queue (events on this queue are only processed when specifically
// called for by code)
hDemandEventQueue = CreateList( QUEUE_RESIZE, sizeof( PTR ) );
if ( hDemandEventQueue == NULL )
{
return( FALSE );
}
return( TRUE );
}
BOOLEAN ShutdownEventManager( )
{
if ( hEventQueue != NULL )
{
DeleteList( hEventQueue );
}
if ( hDelayEventQueue != NULL )
{
DeleteList( hDelayEventQueue );
}
if ( hDemandEventQueue != NULL )
{
DeleteList( hDemandEventQueue );
}
return( TRUE );
}
BOOLEAN AddEvent( UINT32 uiEvent, UINT16 usDelay, PTR pEventData, UINT32 uiDataSize, UINT8 ubQueueID )
{
EVENT *pEvent;
UINT32 uiEventSize = sizeof( EVENT );
HLIST hQueue;
// Allocate new event
pEvent = (EVENT *) MemAlloc( uiEventSize + uiDataSize );
CHECKF( pEvent != NULL );
// Set values
pEvent->TimeStamp = GetJA2Clock( );
pEvent->usDelay = usDelay;
pEvent->uiEvent = uiEvent;
pEvent->uiFlags = 0;
pEvent->uiDataSize = uiDataSize;
pEvent->pData = (BYTE*)pEvent;
pEvent->pData = pEvent->pData + uiEventSize;
memcpy( pEvent->pData, pEventData, uiDataSize );
// Add event to queue
hQueue = GetQueue( ubQueueID );
hQueue = AddtoList( hQueue, &pEvent, ListSize( hQueue ) );
SetQueue( ubQueueID, hQueue );
return( TRUE );
}
BOOLEAN RemoveEvent( EVENT **ppEvent, UINT32 uiIndex, UINT8 ubQueueID )
{
UINT32 uiQueueSize;
HLIST hQueue;
// Get an event from queue, if one exists
//
hQueue = GetQueue( ubQueueID );
// Get Size
uiQueueSize = ListSize( hQueue );
if ( uiQueueSize > 0 )
{
// Get
CHECKF( RemfromList( hQueue , ppEvent, uiIndex ) != FALSE );
}
else
{
return( FALSE );
}
return( TRUE );
}
BOOLEAN PeekEvent( EVENT **ppEvent, UINT32 uiIndex , UINT8 ubQueueID )
{
UINT32 uiQueueSize;
HLIST hQueue;
// Get an event from queue, if one exists
//
hQueue = GetQueue( ubQueueID );
// Get Size
uiQueueSize = ListSize( hQueue );
if ( uiQueueSize > 0 )
{
// Get
CHECKF( PeekList( hQueue, ppEvent, uiIndex ) != FALSE );
}
else
{
return( FALSE );
}
return( TRUE );
}
BOOLEAN FreeEvent( EVENT *pEvent )
{
CHECKF( pEvent != NULL );
// Delete event
MemFree( pEvent );
return( TRUE );
}
UINT32 EventQueueSize( UINT8 ubQueueID )
{
UINT32 uiQueueSize;
HLIST hQueue;
// Get an event from queue, if one exists
//
hQueue = GetQueue( ubQueueID );
// Get Size
uiQueueSize = ListSize( hQueue );
return( uiQueueSize );
}
HLIST GetQueue( UINT8 ubQueueID )
{
switch( ubQueueID )
{
case PRIMARY_EVENT_QUEUE:
return( hEventQueue );
break;
case SECONDARY_EVENT_QUEUE:
return( hDelayEventQueue );
break;
case DEMAND_EVENT_QUEUE:
return( hDemandEventQueue );
break;
default:
Assert( FALSE );
return( 0 );
break;
}
}
void SetQueue( UINT8 ubQueueID, HQUEUE hQueue )
{
switch( ubQueueID )
{
case PRIMARY_EVENT_QUEUE:
hEventQueue = hQueue;
break;
case SECONDARY_EVENT_QUEUE:
hDelayEventQueue = hQueue;
break;
case DEMAND_EVENT_QUEUE:
hDemandEventQueue = hQueue;
break;
default:
Assert( FALSE );
break;
}
}
+33
View File
@@ -0,0 +1,33 @@
#ifndef __EVENT_MANAGER_H
#define __EVENT_MANAGER_H
typedef struct
{
TIMER TimeStamp;
UINT32 uiFlags;
UINT16 usDelay;
UINT32 uiEvent;
UINT32 uiDataSize;
BYTE *pData;
} EVENT;
#define PRIMARY_EVENT_QUEUE 0
#define SECONDARY_EVENT_QUEUE 1
#define DEMAND_EVENT_QUEUE 2
#define EVENT_EXPIRED 0x00000002
// Management fucntions
BOOLEAN InitializeEventManager( );
BOOLEAN ShutdownEventManager( );
BOOLEAN AddEvent( UINT32 uiEvent, UINT16 usDelay, PTR pEventData, UINT32 uiDataSize, UINT8 ubQueueID );
BOOLEAN RemoveEvent( EVENT **ppEvent, UINT32 uiIndex , UINT8 ubQueueID );
BOOLEAN PeekEvent( EVENT **ppEvent, UINT32 uiIndex , UINT8 ubQueueID );
BOOLEAN FreeEvent( EVENT *pEvent );
UINT32 EventQueueSize( UINT8 ubQueueID );
#endif
+1258
View File
File diff suppressed because it is too large Load Diff
+257
View File
@@ -0,0 +1,257 @@
#ifndef EVENT_PROCESSOR_H
#define EVENT_PROCESSOR_H
#include "Event Manager.h"
#define NETWORK_PATH_DATA_SIZE 6
// Enumerate all events for JA2
enum eJA2Events
{
E_PLAYSOUND,
S_CHANGEDEST,
// S_GETNEWPATH,
S_BEGINTURN,
S_CHANGESTANCE,
S_SETDESIREDDIRECTION,
S_BEGINFIREWEAPON,
S_FIREWEAPON,
S_WEAPONHIT,
S_STRUCTUREHIT,
S_WINDOWHIT,
S_MISS,
S_NOISE,
S_STOP_MERC,
EVENTS_LOCAL_AND_NETWORK, // Events above here are sent locally and over network
S_GETNEWPATH,
S_SETPOSITION,
S_CHANGESTATE,
S_SETDIRECTION,
EVENTS_ONLY_USED_LOCALLY, // Events above are only used locally
S_SENDPATHTONETWORK,
S_UPDATENETWORKSOLDIER,
EVENTS_ONLY_SENT_OVER_NETWORK, // Events above are only sent to the network
NUM_EVENTS
} ;
// This definition is used to denote events with a special delay value;
// it indicates that these events will not be processed until specifically
// called for in a special loop.
#define DEMAND_EVENT_DELAY 0xFFFF
// Enumerate all structures for events
typedef struct
{
UINT16 usIndex;
UINT16 usRate;
UINT8 ubVolume;
UINT8 ubLoops;
UINT32 uiPan;
} EV_E_PLAYSOUND;
typedef struct
{
UINT16 usSoldierID;
UINT32 uiUniqueId;
UINT16 usNewState;
INT16 sXPos;
INT16 sYPos;
UINT16 usStartingAniCode;
BOOLEAN fForce;
} EV_S_CHANGESTATE;
typedef struct
{
UINT16 usSoldierID;
UINT32 uiUniqueId;
UINT16 usNewDestination;
} EV_S_CHANGEDEST;
typedef struct
{
UINT16 usSoldierID;
UINT32 uiUniqueId;
FLOAT dNewXPos;
FLOAT dNewYPos;
} EV_S_SETPOSITION;
typedef struct
{
UINT16 usSoldierID;
UINT32 uiUniqueId;
INT16 sDestGridNo;
UINT16 usMovementAnim;
} EV_S_GETNEWPATH;
typedef struct
{
UINT16 usSoldierID;
UINT32 uiUniqueId;
} EV_S_BEGINTURN;
typedef struct
{
UINT16 usSoldierID;
UINT32 uiUniqueId;
UINT8 ubNewStance;
INT16 sXPos;
INT16 sYPos;
} EV_S_CHANGESTANCE;
typedef struct
{
UINT16 usSoldierID;
UINT32 uiUniqueId;
UINT16 usNewDirection;
} EV_S_SETDIRECTION;
typedef struct
{
UINT16 usSoldierID;
UINT32 uiUniqueId;
UINT16 usDesiredDirection;
} EV_S_SETDESIREDDIRECTION;
typedef struct
{
UINT16 usSoldierID;
UINT32 uiUniqueId;
INT16 sTargetGridNo;
INT8 bTargetLevel;
INT8 bTargetCubeLevel;
} EV_S_BEGINFIREWEAPON;
typedef struct
{
UINT16 usSoldierID;
UINT32 uiUniqueId;
INT16 sTargetGridNo;
INT8 bTargetLevel;
INT8 bTargetCubeLevel;
} EV_S_FIREWEAPON;
typedef struct
{
UINT16 usSoldierID;
UINT32 uiUniqueId;
UINT16 usWeaponIndex;
INT16 sDamage;
INT16 sBreathLoss;
UINT16 usDirection;
INT16 sXPos;
INT16 sYPos;
INT16 sZPos;
INT16 sRange;
UINT8 ubAttackerID;
BOOLEAN fHit;
UINT8 ubSpecial;
UINT8 ubLocation;
} EV_S_WEAPONHIT;
typedef struct
{
INT16 sXPos;
INT16 sYPos;
INT16 sZPos;
UINT16 usWeaponIndex;
INT8 bWeaponStatus;
UINT8 ubAttackerID;
UINT16 usStructureID;
INT32 iImpact;
INT32 iBullet;
} EV_S_STRUCTUREHIT;
typedef struct
{
INT16 sGridNo;
UINT16 usStructureID;
BOOLEAN fBlowWindowSouth;
BOOLEAN fLargeForce;
} EV_S_WINDOWHIT;
typedef struct
{
UINT8 ubAttackerID;
} EV_S_MISS;
typedef struct
{
UINT8 ubNoiseMaker;
INT16 sGridNo;
UINT8 bLevel;
UINT8 ubTerrType;
UINT8 ubVolume;
UINT8 ubNoiseType;
} EV_S_NOISE;
typedef struct
{
UINT16 usSoldierID;
UINT32 uiUniqueId;
INT8 bDirection;
INT16 sGridNo;
INT16 sXPos;
INT16 sYPos;
} EV_S_STOP_MERC;
typedef struct
{
UINT8 usSoldierID;
UINT32 uiUniqueId;
UINT8 usPathDataSize; // Size of Path
INT16 sAtGridNo; // Owner merc is at this tile when sending packet
UINT8 usCurrentPathIndex; // Index the owner of the merc is at when sending packet
UINT8 usPathData[ NETWORK_PATH_DATA_SIZE ]; // make define // Next X tile to go to
UINT8 ubNewState; // new movment Anim
// INT8 bActionPoints;
// INT8 bBreath; // current breath value
// INT8 bDesiredDirection;
// maybe send current action & breath points
} EV_S_SENDPATHTONETWORK;
typedef struct
{
UINT8 usSoldierID;
UINT32 uiUniqueId;
INT16 sAtGridNo; // Owner merc is at this tile when sending packet
INT8 bActionPoints; // current A.P. value
INT8 bBreath; // current breath value
} EV_S_UPDATENETWORKSOLDIER;
// FUNCTIONS
BOOLEAN AddGameEvent( UINT32 uiEvent, UINT16 usDelay, PTR pEventData );
BOOLEAN AddGameEventFromNetwork( UINT32 uiEvent, UINT16 usDelay, PTR pEventData );
BOOLEAN DequeAllGameEvents( BOOLEAN fExecute );
BOOLEAN DequeueAllDemandGameEvents( BOOLEAN fExecute );
// clean out the evetn queue
BOOLEAN ClearEventQueue( void );
#endif
+371
View File
@@ -0,0 +1,371 @@
#ifdef PRECOMPILEDHEADERS
#include "Utils All.h"
#include "winfont.h"
#else
#include <stdio.h>
#include <stdarg.h>
#include <time.h>
#include "sgp.h"
#include "himage.h"
#include "vsurface.h"
#include "vsurface_private.h"
#include "wcheck.h"
#include "Font Control.h"
#endif
INT32 giCurWinFont = 0;
BOOLEAN gfUseWinFonts = FALSE;
// Global variables for video objects
INT32 gpLargeFontType1;
HVOBJECT gvoLargeFontType1;
INT32 gpSmallFontType1;
HVOBJECT gvoSmallFontType1;
INT32 gpTinyFontType1;
HVOBJECT gvoTinyFontType1;
INT32 gp12PointFont1;
HVOBJECT gvo12PointFont1;
INT32 gpClockFont;
HVOBJECT gvoClockFont;
INT32 gpCompFont;
HVOBJECT gvoCompFont;
INT32 gpSmallCompFont;
HVOBJECT gvoSmallCompFont;
INT32 gp10PointRoman;
HVOBJECT gvo10PointRoman;
INT32 gp12PointRoman;
HVOBJECT gvo12PointRoman;
INT32 gp14PointSansSerif;
HVOBJECT gvo14PointSansSerif;
//INT32 gpMilitaryFont1;
//HVOBJECT gvoMilitaryFont1;
INT32 gp10PointArial;
HVOBJECT gvo10PointArial;
INT32 gp10PointArialBold;
HVOBJECT gvo10PointArialBold;
INT32 gp14PointArial;
HVOBJECT gvo14PointArial;
INT32 gp12PointArial;
HVOBJECT gvo12PointArial;
INT32 gpBlockyFont;
HVOBJECT gvoBlockyFont;
INT32 gpBlockyFont2;
HVOBJECT gvoBlockyFont2;
INT32 gp12PointArialFixedFont;
HVOBJECT gvo12PointArialFixedFont;
INT32 gp16PointArial;
HVOBJECT gvo16PointArial;
INT32 gpBlockFontNarrow;
HVOBJECT gvoBlockFontNarrow;
INT32 gp14PointHumanist;
HVOBJECT gvo14PointHumanist;
#if defined( JA2EDITOR ) && defined( ENGLISH )
INT32 gpHugeFont;
HVOBJECT gvoHugeFont;
#endif
INT32 giSubTitleWinFont;
BOOLEAN gfFontsInit = FALSE;
UINT16 CreateFontPaletteTables(HVOBJECT pObj );
extern UINT16 gzFontName[32];
BOOLEAN InitializeFonts( )
{
//INT16 zWinFontName[128]; // unused (jonathanl)
//COLORVAL Color; // usused (jonathanl)
// Initialize fonts
// gpLargeFontType1 = LoadFontFile( "FONTS\\lfont1.sti" );
gpLargeFontType1 = LoadFontFile( "FONTS\\LARGEFONT1.sti" );
gvoLargeFontType1 = GetFontObject( gpLargeFontType1 );
CHECKF( CreateFontPaletteTables( gvoLargeFontType1 ) );
// gpSmallFontType1 = LoadFontFile( "FONTS\\6b-font.sti" );
gpSmallFontType1 = LoadFontFile( "FONTS\\SMALLFONT1.sti" );
gvoSmallFontType1 = GetFontObject( gpSmallFontType1 );
CHECKF( CreateFontPaletteTables( gvoSmallFontType1 ) );
// gpTinyFontType1 = LoadFontFile( "FONTS\\tfont1.sti" );
gpTinyFontType1 = LoadFontFile( "FONTS\\TINYFONT1.sti" );
gvoTinyFontType1 = GetFontObject( gpTinyFontType1 );
CHECKF( CreateFontPaletteTables( gvoTinyFontType1 ) );
// gp12PointFont1 = LoadFontFile( "FONTS\\font-12.sti" );
gp12PointFont1 = LoadFontFile( "FONTS\\FONT12POINT1.sti" );
gvo12PointFont1 = GetFontObject( gp12PointFont1 );
CHECKF( CreateFontPaletteTables( gvo12PointFont1 ) );
// gpClockFont = LoadFontFile( "FONTS\\DIGI.sti" );
gpClockFont = LoadFontFile( "FONTS\\CLOCKFONT.sti" );
gvoClockFont = GetFontObject( gpClockFont );
CHECKF( CreateFontPaletteTables( gvoClockFont ) );
// gpCompFont = LoadFontFile( "FONTS\\compfont.sti" );
gpCompFont = LoadFontFile( "FONTS\\COMPFONT.sti" );
gvoCompFont = GetFontObject( gpCompFont );
CHECKF( CreateFontPaletteTables( gvoCompFont ) );
// gpSmallCompFont = LoadFontFile( "FONTS\\scfont.sti" );
gpSmallCompFont = LoadFontFile( "FONTS\\SMALLCOMPFONT.sti" );
gvoSmallCompFont = GetFontObject( gpSmallCompFont );
CHECKF( CreateFontPaletteTables( gvoSmallCompFont ) );
// gp10PointRoman = LoadFontFile( "FONTS\\Roman10.sti" );
gp10PointRoman = LoadFontFile( "FONTS\\FONT10ROMAN.sti" );
gvo10PointRoman = GetFontObject( gp10PointRoman );
CHECKF( CreateFontPaletteTables( gvo10PointRoman ) );
// gp12PointRoman = LoadFontFile( "FONTS\\Roman12.sti" );
gp12PointRoman = LoadFontFile( "FONTS\\FONT12ROMAN.sti" );
gvo12PointRoman = GetFontObject( gp12PointRoman );
CHECKF( CreateFontPaletteTables( gvo12PointRoman ) );
// gp14PointSansSerif = LoadFontFile( "FONTS\\SansSerif14.sti" );
gp14PointSansSerif = LoadFontFile( "FONTS\\FONT14SANSERIF.sti" );
gvo14PointSansSerif = GetFontObject( gp14PointSansSerif);
CHECKF( CreateFontPaletteTables( gvo14PointSansSerif) );
// DEF: Removed. Replaced with BLOCKFONT
// gpMilitaryFont1 = LoadFontFile( "FONTS\\milfont.sti" );
// gvoMilitaryFont1 = GetFontObject( gpMilitaryFont1);
// CHECKF( CreateFontPaletteTables( gvoMilitaryFont1) );
// gp10PointArial = LoadFontFile( "FONTS\\Arial10.sti" );
gp10PointArial = LoadFontFile( "FONTS\\FONT10ARIAL.sti" );
gvo10PointArial = GetFontObject( gp10PointArial);
CHECKF( CreateFontPaletteTables( gvo10PointArial) );
// gp14PointArial = LoadFontFile( "FONTS\\Arial14.sti" );
gp14PointArial = LoadFontFile( "FONTS\\FONT14ARIAL.sti" );
gvo14PointArial = GetFontObject( gp14PointArial);
CHECKF( CreateFontPaletteTables( gvo14PointArial) );
// gp10PointArialBold = LoadFontFile( "FONTS\\Arial10Bold2.sti" );
gp10PointArialBold = LoadFontFile( "FONTS\\FONT10ARIALBOLD.sti" );
gvo10PointArialBold = GetFontObject( gp10PointArialBold);
CHECKF( CreateFontPaletteTables( gvo10PointArialBold) );
// gp12PointArial = LoadFontFile( "FONTS\\Arial12.sti" );
gp12PointArial = LoadFontFile( "FONTS\\FONT12ARIAL.sti" );
gvo12PointArial = GetFontObject( gp12PointArial);
CHECKF( CreateFontPaletteTables( gvo12PointArial) );
// gpBlockyFont = LoadFontFile( "FONTS\\FONT2.sti" );
gpBlockyFont = LoadFontFile( "FONTS\\BLOCKFONT.sti" );
gvoBlockyFont = GetFontObject( gpBlockyFont);
CHECKF( CreateFontPaletteTables( gvoBlockyFont) );
// gpBlockyFont2 = LoadFontFile( "FONTS\\interface_font.sti" );
gpBlockyFont2 = LoadFontFile( "FONTS\\BLOCKFONT2.sti" );
gvoBlockyFont2 = GetFontObject( gpBlockyFont2);
CHECKF( CreateFontPaletteTables( gvoBlockyFont2) );
// gp12PointArialFixedFont = LoadFontFile( "FONTS\\Arial12FixedWidth.sti" );
gp12PointArialFixedFont = LoadFontFile( "FONTS\\FONT12ARIALFIXEDWIDTH.sti" );
gvo12PointArialFixedFont = GetFontObject( gp12PointArialFixedFont );
CHECKF( CreateFontPaletteTables( gvo12PointArialFixedFont ) );
gp16PointArial = LoadFontFile( "FONTS\\FONT16ARIAL.sti" );
gvo16PointArial = GetFontObject( gp16PointArial );
CHECKF( CreateFontPaletteTables( gvo16PointArial ) );
gpBlockFontNarrow = LoadFontFile( "FONTS\\BLOCKFONTNARROW.sti" );
gvoBlockFontNarrow = GetFontObject( gpBlockFontNarrow );
CHECKF( CreateFontPaletteTables( gvoBlockFontNarrow ) );
gp14PointHumanist = LoadFontFile( "FONTS\\FONT14HUMANIST.sti" );
gvo14PointHumanist = GetFontObject( gp14PointHumanist );
CHECKF( CreateFontPaletteTables( gvo14PointHumanist ) );
#if defined( JA2EDITOR ) && defined( ENGLISH )
gpHugeFont = LoadFontFile( "FONTS\\HUGEFONT.sti" );
gvoHugeFont = GetFontObject( gpHugeFont );
CHECKF( CreateFontPaletteTables( gvoHugeFont ) );
#endif
// Set default for font system
SetFontDestBuffer( FRAME_BUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, FALSE );
gfFontsInit = TRUE;
// ATE: Init WinFont System and any winfonts we wish...
#ifdef WINFONTS
InitWinFonts( );
//giSubTitleWinFont = CreateWinFont( -16, 0, 0, 0, FALSE, FALSE, FALSE, L"¼Ð·¢Åé", CHINESEBIG5_CHARSET );
giSubTitleWinFont = CreateWinFont( -16, 0, 0, 0, FALSE, FALSE, FALSE, L"·s²Ó©úÅé", CHINESEBIG5_CHARSET );
SET_USE_WINFONTS( TRUE );
SET_WINFONT( giSubTitleWinFont );
Color = FROMRGB( 255, 255, 255 );
SetWinFontForeColor( giSubTitleWinFont, &Color );
PrintWinFont( FRAME_BUFFER, giSubTitleWinFont, 10, 100, L"Font %s initialized", gzFontName );
InvalidateScreen();
RefreshScreen( NULL );
SET_USE_WINFONTS( FALSE );
#endif
return( TRUE );
}
void ShutdownFonts( )
{
UnloadFont( gpLargeFontType1 );
UnloadFont( gpSmallFontType1 );
UnloadFont( gpTinyFontType1 );
UnloadFont( gp12PointFont1 );
UnloadFont( gpClockFont);
UnloadFont( gpCompFont);
UnloadFont( gpSmallCompFont);
UnloadFont( gp10PointRoman);
UnloadFont( gp12PointRoman);
UnloadFont( gp14PointSansSerif);
// UnloadFont( gpMilitaryFont1);
UnloadFont( gp10PointArial);
UnloadFont( gp10PointArialBold);
UnloadFont( gp14PointArial);
UnloadFont( gpBlockyFont);
UnloadFont( gp12PointArialFixedFont );
#if defined( JA2EDITOR ) && defined( ENGLISH )
UnloadFont( gpHugeFont );
#endif
// ATE: Shutdown any win fonts
#ifdef WINFONTS
DeleteWinFont( giSubTitleWinFont );
#endif
}
// Set shades for fonts
BOOLEAN SetFontShade( UINT32 uiFontID, INT8 bColorID )
{
HVOBJECT pFont;
CHECKF( bColorID > 0 );
CHECKF( bColorID < 16 );
pFont = GetFontObject( uiFontID );
pFont->pShadeCurrent = pFont->pShades[ bColorID ];
return( TRUE );
}
UINT16 CreateFontPaletteTables(HVOBJECT pObj )
{
UINT32 count;
SGPPaletteEntry Pal[256];
for( count = 0; count < 16; count++ )
{
if ( (count == 4) && (pObj->p16BPPPalette == pObj->pShades[ count ]) )
pObj->pShades[ count ] = NULL;
else if ( pObj->pShades[ count ] != NULL )
{
MemFree( pObj->pShades[ count ] );
pObj->pShades[ count ] = NULL;
}
}
// Build white palette
for(count=0; count < 256; count++)
{
Pal[count].peRed=(UINT8)255;
Pal[count].peGreen=(UINT8)255;
Pal[count].peBlue=(UINT8)255;
}
pObj->pShades[ FONT_SHADE_RED ]=Create16BPPPaletteShaded( pObj->pPaletteEntry, 255, 0, 0, TRUE);
pObj->pShades[ FONT_SHADE_BLUE ]=Create16BPPPaletteShaded( pObj->pPaletteEntry, 0, 0, 255, TRUE);
pObj->pShades[ FONT_SHADE_GREEN ]=Create16BPPPaletteShaded( pObj->pPaletteEntry, 0, 255, 0, TRUE);
pObj->pShades[ FONT_SHADE_YELLOW ]=Create16BPPPaletteShaded( pObj->pPaletteEntry, 255, 255, 0, TRUE);
pObj->pShades[ FONT_SHADE_NEUTRAL ]=Create16BPPPaletteShaded( pObj->pPaletteEntry, 255, 255, 255, FALSE);
pObj->pShades[ FONT_SHADE_WHITE ]=Create16BPPPaletteShaded( pObj->pPaletteEntry, 255, 255, 255, TRUE);
// the rest are darkening tables, right down to all-black.
pObj->pShades[0]=Create16BPPPaletteShaded( pObj->pPaletteEntry, 165, 165, 165, FALSE);
pObj->pShades[7]=Create16BPPPaletteShaded( pObj->pPaletteEntry, 135, 135, 135, FALSE);
pObj->pShades[8]=Create16BPPPaletteShaded( pObj->pPaletteEntry, 105, 105, 105, FALSE);
pObj->pShades[9]=Create16BPPPaletteShaded( pObj->pPaletteEntry, 75, 75, 75, FALSE);
pObj->pShades[10]=Create16BPPPaletteShaded( pObj->pPaletteEntry, 45, 45, 45, FALSE);
pObj->pShades[11]=Create16BPPPaletteShaded( pObj->pPaletteEntry, 36, 36, 36, FALSE);
pObj->pShades[12]=Create16BPPPaletteShaded( pObj->pPaletteEntry, 27, 27, 27, FALSE);
pObj->pShades[13]=Create16BPPPaletteShaded( pObj->pPaletteEntry, 18, 18, 18, FALSE);
pObj->pShades[14]=Create16BPPPaletteShaded( pObj->pPaletteEntry, 9, 9, 9, FALSE);
pObj->pShades[15]=Create16BPPPaletteShaded( pObj->pPaletteEntry, 0, 0, 0, FALSE);
// Set current shade table to neutral color
pObj->pShadeCurrent=pObj->pShades[4];
// check to make sure every table got a palette
//for(count=0; (count < HVOBJECT_SHADE_TABLES) && (pObj->pShades[count]!=NULL); count++);
// return the result of the check
//return(count==HVOBJECT_SHADE_TABLES);
return(TRUE);
}
UINT16 WFGetFontHeight( INT32 FontNum )
{
if ( USE_WINFONTS( ) )
{
// return how many Y pixels we used
return( GetWinFontHeight( L"a\0", GET_WINFONT( ) ) );
}
else
{
// return how many Y pixels we used
return( GetFontHeight( FontNum ) );
}
}
INT16 WFStringPixLength( UINT16 *string,INT32 UseFont )
{
if ( USE_WINFONTS( ) )
{
// return how many Y pixels we used
return( WinFontStringPixLength( string, GET_WINFONT( ) ) );
}
else
{
// return how many Y pixels we used
return( StringPixLength( string, UseFont ) );
}
}
+194
View File
@@ -0,0 +1,194 @@
#ifndef __FONT_CONTROL_H
#define __FONT_CONTROL_H
#include "builddefines.h"
#include "font.h"
extern BOOLEAN gfUseWinFonts;
extern INT32 giCurWinFont;
// ATE: Use this define to enable winfonts in JA2
// #define WINFONTS
#ifdef WINFONTS
#define USE_WINFONTS( ) ( gfUseWinFonts )
#else
#define USE_WINFONTS( ) ( FALSE )
#endif
#define GET_WINFONT( ) ( giCurWinFont )
#define SET_USE_WINFONTS( fSet ) ( gfUseWinFonts = fSet );
#define SET_WINFONT( fFont ) ( giCurWinFont = fFont );
// ATE: A few winfont wrappers..
UINT16 WFGetFontHeight( INT32 FontNum );
INT16 WFStringPixLength( UINT16 *string,INT32 UseFont );
// Global variables for video objects
extern INT32 gpLargeFontType1;
extern HVOBJECT gvoLargeFontType1;
extern INT32 gpSmallFontType1;
extern HVOBJECT gvoSmallFontType1;
extern INT32 gpTinyFontType1;
extern HVOBJECT gvoTinyFontType1;
extern INT32 gp12PointFont1;
extern HVOBJECT gvo12PointFont1;
extern INT32 gpClockFont;
extern HVOBJECT gvoClockFont;
extern INT32 gpCompFont;
extern HVOBJECT gvoCompFont;
extern INT32 gpSmallCompFont;
extern HVOBJECT gvoSmallCompFont;
extern INT32 gp10PointRoman;
extern HVOBJECT gvo10PointRoman;
extern INT32 gp12PointRoman;
extern HVOBJECT gvo12PointRoman;
extern INT32 gp14PointSansSerif;
extern HVOBJECT gvo14PointSansSerif;
//INT32 gpMilitaryFont1;
//HVOBJECT gvoMilitaryFont1;
extern INT32 gp10PointArial;
extern HVOBJECT gvo10PointArial;
extern INT32 gp14PointArial;
extern HVOBJECT gvo14PointArial;
extern INT32 gp12PointArial;
extern HVOBJECT gvo12PointArial;
extern INT32 gpBlockyFont;
extern HVOBJECT gvoBlockyFont;
extern INT32 gpBlockyFont2;
extern HVOBJECT gvoBlockyFont2;
extern INT32 gp10PointArialBold;
extern HVOBJECT gvo10PointArialBold;
extern INT32 gp12PointArialFixedFont;
extern HVOBJECT gvo12PointArialFixedFont;
extern INT32 gp16PointArial;
extern HVOBJECT gvo16PointArial;
extern INT32 gpBlockFontNarrow;
extern HVOBJECT gvoBlockFontNarrow;
extern INT32 gp14PointHumanist;
extern HVOBJECT gvo14PointHumanist;
#ifdef JA2EDITOR
extern INT32 gpHugeFont;
extern HVOBJECT gvoHugeFont;
#endif
extern INT32 giSubTitleWinFont;
extern BOOLEAN gfFontsInit;
// Defines
#define LARGEFONT1 gpLargeFontType1
#define SMALLFONT1 gpSmallFontType1
#define TINYFONT1 gpTinyFontType1
#define FONT12POINT1 gp12PointFont1
#define CLOCKFONT gpClockFont
#define COMPFONT gpCompFont
#define SMALLCOMPFONT gpSmallCompFont
#define FONT10ROMAN gp10PointRoman
#define FONT12ROMAN gp12PointRoman
#define FONT14SANSERIF gp14PointSansSerif
#define MILITARYFONT1 BLOCKFONT //gpMilitaryFont1
#define FONT10ARIAL gp10PointArial
#define FONT14ARIAL gp14PointArial
#define FONT12ARIAL gp12PointArial
#define FONT10ARIALBOLD gp10PointArialBold
#define BLOCKFONT gpBlockyFont
#define BLOCKFONT2 gpBlockyFont2
#define FONT12ARIALFIXEDWIDTH gp12PointArialFixedFont
#define FONT16ARIAL gp16PointArial
#define BLOCKFONTNARROW gpBlockFontNarrow
#define FONT14HUMANIST gp14PointHumanist
#if defined( JA2EDITOR ) && defined( ENGLISH )
#define HUGEFONT gpHugeFont
#else
#define HUGEFONT gp16PointArial
#endif
#define FONT_SHADE_RED 6
#define FONT_SHADE_BLUE 1
#define FONT_SHADE_GREEN 2
#define FONT_SHADE_YELLOW 3
#define FONT_SHADE_NEUTRAL 4
#define FONT_SHADE_WHITE 5
#define FONT_MCOLOR_BLACK 0
#define FONT_MCOLOR_WHITE 208
#define FONT_MCOLOR_DKWHITE 134
#define FONT_MCOLOR_DKWHITE2 134
#define FONT_MCOLOR_LTGRAY 134
#define FONT_MCOLOR_LTGRAY2 134
#define FONT_MCOLOR_DKGRAY 136
#define FONT_MCOLOR_LTBLUE 203
#define FONT_MCOLOR_LTRED 162
#define FONT_MCOLOR_RED 163
#define FONT_MCOLOR_DKRED 164
#define FONT_MCOLOR_LTGREEN 184
#define FONT_MCOLOR_LTYELLOW 144
//Grayscale font colors
#define FONT_WHITE 208 //lightest color
#define FONT_GRAY1 133
#define FONT_GRAY2 134 //light gray
#define FONT_GRAY3 135
#define FONT_GRAY4 136 //gray
#define FONT_GRAY5 137
#define FONT_GRAY6 138
#define FONT_GRAY7 139 //dark gray
#define FONT_GRAY8 140
#define FONT_NEARBLACK 141
#define FONT_BLACK 0 //darkest color
//Color font colors
#define FONT_LTRED 162
#define FONT_RED 163
#define FONT_DKRED 218
#define FONT_ORANGE 76
#define FONT_YELLOW 145
#define FONT_DKYELLOW 80
#define FONT_LTGREEN 184
#define FONT_GREEN 185
#define FONT_DKGREEN 186
#define FONT_LTBLUE 71
#define FONT_BLUE 203
#define FONT_DKBLUE 205
#define FONT_BEIGE 130
#define FONT_METALGRAY 94
#define FONT_BURGUNDY 172
#define FONT_LTKHAKI 88
#define FONT_KHAKI 198
#define FONT_DKKHAKI 201
BOOLEAN InitializeFonts( );
void ShutdownFonts( );
BOOLEAN SetFontShade( UINT32 uiFontID, INT8 bColorID );
#endif
+63
View File
@@ -0,0 +1,63 @@
#include "IniReader.h"
#include "FileMan.h"
#include <stdio.h>
#include <string.h>
// Kaiden: INI reading function definitions:
CIniReader::CIniReader(const char* szFileName)
{
// Snap: Look for the INI file in the custom Data directory.
// If not there, leave at default location.
if ( gCustomDataCat.FindFile(szFileName) ) {
sprintf(m_szFileName, "%s\\%s", gCustomDataCat.GetRootDir().c_str(), szFileName);
}
else {
sprintf(m_szFileName, "%s\\%s", gDefaultDataCat.GetRootDir().c_str(), szFileName);
}
}
int CIniReader::ReadInteger(const char* szSection, const char* szKey, int iDefaultValue)
{
return GetPrivateProfileInt(szSection, szKey, iDefaultValue, m_szFileName);
}
float CIniReader::ReadFloat(const char* szSection, const char* szKey, float fltDefaultValue)
{
char szResult[255];
char szDefault[255];
float fltResult;
sprintf(szDefault, "%f",fltDefaultValue);
GetPrivateProfileString(szSection, szKey, szDefault, szResult, 255, m_szFileName);
fltResult = (float) atof(szResult);
return fltResult;
}
bool CIniReader::ReadBoolean(const char* szSection, const char* szKey, bool bolDefaultValue)
{
char szResult[255];
char szDefault[255];
bool bolResult;
sprintf(szDefault, "%s", bolDefaultValue? "TRUE" : "FALSE");
GetPrivateProfileString(szSection, szKey, szDefault, szResult, 255, m_szFileName);
bolResult = (strcmp(szResult, "TRUE") == 0 || strcmp(szResult, "TRUE") == 0) ? true : false;
return bolResult;
}
char* CIniReader::ReadString(const char* szSection, const char* szKey, const char* szDefaultValue)
{
char* szResult = new char[255];
memset(szResult, 0x00, 255);
GetPrivateProfileString(szSection, szKey, szDefaultValue, szResult, 255, m_szFileName);
return szResult;
}
+21
View File
@@ -0,0 +1,21 @@
#ifndef INIREADER_H
#define INIREADER_H
#include <Windows.h>
// Kaiden: This will read any value out of
// an INI file as long as the correct type is specified.
// Methods should be fairly self explainatory:
class CIniReader
{
public:
CIniReader(const char* szFileName);
int ReadInteger(const char* szSection, const char* szKey, int iDefaultValue);
float ReadFloat(const char* szSection, const char* szKey, float fltDefaultValue);
bool ReadBoolean(const char* szSection, const char* szKey, bool bolDefaultValue);
char* ReadString(const char* szSection, const char* szKey, const char* szDefaultValue);
private:
char m_szFileName[MAX_PATH];
};
#endif//INIREADER_H
+372
View File
@@ -0,0 +1,372 @@
#ifdef PRECOMPILEDHEADERS
#include "Utils All.h"
#else
#include "sgp.h"
#ifdef JA2EDITOR
#include "Screens.h"
#include "Maputility.h"
#include "worlddef.h"
#include "overhead.h"
#include "fileman.h"
#include "loadscreen.h"
#include "overhead map.h"
#include "radar screen.h"
#include "vobject_blitters.h"
#include "sticonvert.h"
#include "font control.h"
#include "worlddat.h"
#include "english.h"
#include "map information.h"
#include "line.h"
#endif
#endif
#ifdef JA2EDITOR
#include "quantize wrap.h"
#define MINIMAP_X_SIZE 88
#define MINIMAP_Y_SIZE 44
#define WINDOW_SIZE 2
FLOAT gdXStep, gdYStep;
INT32 giMiniMap, gi8BitMiniMap;
HVSURFACE ghvSurface;
extern BOOLEAN gfOverheadMapDirty;
extern int iOffsetHorizontal;
extern int iOffsetVertical;
// Utililty file for sub-sampling/creating our radar screen maps
// Loops though our maps directory and reads all .map files, subsamples an area, color
// quantizes it into an 8-bit image ans writes it to an sti file in radarmaps.
typedef struct
{
INT8 r;
INT8 g;
INT8 b;
} RGBValues;
UINT32 MapUtilScreenInit( )
{
return( TRUE );
}
UINT32 MapUtilScreenHandle( )
{
static INT16 fNewMap = TRUE;
static INT16 sFileNum = 0;
InputAtom InputEvent;
GETFILESTRUCT FileInfo;
static FDLG_LIST *FListNode;
static INT16 sFiles = 0, sCurFile = 0;
static FDLG_LIST *FileList = NULL;
INT8 zFilename[ 260 ], zFilename2[ 260 ];
VSURFACE_DESC vs_desc;
UINT16 usWidth;
UINT16 usHeight;
UINT8 ubBitDepth;
UINT32 uiDestPitchBYTES, uiSrcPitchBYTES;
UINT16 *pDestBuf, *pSrcBuf;
UINT8 *pDataPtr;
static UINT8 *p24BitDest = NULL;
static RGBValues *p24BitValues=NULL;
UINT32 uiRGBColor;
UINT32 bR, bG, bB, bAvR, bAvG, bAvB;
INT16 s16BPPSrc, sDest16BPPColor;
INT32 cnt;
INT16 sX1, sX2, sY1, sY2, sTop, sBottom, sLeft, sRight;
FLOAT dX, dY, dStartX, dStartY;
INT32 iX, iY, iSubX1, iSubY1, iSubX2, iSubY2, iWindowX, iWindowY, iCount;
SGPPaletteEntry pPalette[ 256 ];
sDest16BPPColor = -1;
bAvR = bAvG = bAvB = 0;
// Zero out area!
ColorFillVideoSurfaceArea( FRAME_BUFFER, 0, 0, (INT16)(SCREEN_WIDTH), (INT16)(SCREEN_HEIGHT), Get16BPPColor( FROMRGB( 0, 0, 0 ) ) );
if ( fNewMap )
{
fNewMap = FALSE;
// Create render buffer
GetCurrentVideoSettings( &usWidth, &usHeight, &ubBitDepth );
vs_desc.fCreateFlags = VSURFACE_CREATE_DEFAULT | VSURFACE_SYSTEM_MEM_USAGE;
vs_desc.usWidth = 88;
vs_desc.usHeight = 44;
vs_desc.ubBitDepth = ubBitDepth;
if ( AddVideoSurface( &vs_desc, (UINT32 *)&giMiniMap ) == FALSE )
{
return( ERROR_SCREEN );
}
// USING BRET's STUFF FOR LOOPING FILES/CREATING LIST, hence AddToFDlgList.....
if( GetFileFirst("MAPS\\*.dat", &FileInfo) )
{
FileList = AddToFDlgList( FileList, &FileInfo );
sFiles++;
while( GetFileNext(&FileInfo) )
{
FileList = AddToFDlgList( FileList, &FileInfo );
sFiles++;
}
GetFileClose(&FileInfo);
}
FListNode = FileList;
//Allocate 24 bit Surface
p24BitValues = (RGBValues *) MemAlloc( MINIMAP_X_SIZE * MINIMAP_Y_SIZE * sizeof( RGBValues ) );
p24BitDest = (UINT8*)p24BitValues;
//Allocate 8-bit surface
vs_desc.fCreateFlags = VSURFACE_CREATE_DEFAULT | VSURFACE_SYSTEM_MEM_USAGE;
vs_desc.usWidth = 88;
vs_desc.usHeight = 44;
vs_desc.ubBitDepth = 8;
if ( AddVideoSurface( &vs_desc, (UINT32 *)&gi8BitMiniMap ) == FALSE )
{
return( ERROR_SCREEN );
}
GetVideoSurface( &ghvSurface, gi8BitMiniMap );
}
//OK, we are here, now loop through files
if ( sCurFile == sFiles || FListNode== NULL )
{
gfProgramIsRunning = FALSE;
return( MAPUTILITY_SCREEN );
}
sprintf( (char *)zFilename, "%s", FListNode->FileInfo.zFileName );
// OK, load maps and do overhead shrinkage of them...
if ( !LoadWorld( (UINT8 *)zFilename ) )
{
return( ERROR_SCREEN );
}
// Render small map
InitNewOverheadDB( (UINT8)giCurrentTilesetID );
gfOverheadMapDirty = TRUE;
RenderOverheadMap( 0, (WORLD_COLS / 2), iOffsetHorizontal,
iOffsetVertical, 640 + iOffsetHorizontal, 320 + iOffsetVertical, FALSE );
TrashOverheadMap( );
// OK, NOW PROCESS OVERHEAD MAP ( SHOUIDL BE ON THE FRAMEBUFFER )
gdXStep = (float)640/(float)88;
gdYStep = (float)320/(float)44;
dStartX = dStartY = 0;
// Adjust if we are using a restricted map...
if ( gMapInformation.ubRestrictedScrollID != 0 )
{
CalculateRestrictedMapCoords( NORTH, &sX1, &sY1, &sX2, &sTop, iOffsetHorizontal + 640, iOffsetVertical + 320 );
CalculateRestrictedMapCoords( SOUTH, &sX1, &sBottom, &sX2, &sY2, iOffsetHorizontal + 640, iOffsetVertical + 320 );
CalculateRestrictedMapCoords( WEST, &sX1, &sY1, &sLeft, &sY2, iOffsetHorizontal + 640, iOffsetVertical + 320 );
CalculateRestrictedMapCoords( EAST, &sRight, &sY1, &sX2, &sY2, iOffsetHorizontal + 640, iOffsetVertical + 320 );
gdXStep = (float)( sRight - sLeft )/(float)88;
gdYStep = (float)( sBottom - sTop )/(float)44;
dStartX = sLeft;
dStartY = sTop;
}
//LOCK BUFFERS
dX = dStartX;
dY = dStartY;
pDestBuf = (UINT16*)LockVideoSurface(giMiniMap, &uiDestPitchBYTES);
pSrcBuf = (UINT16*)LockVideoSurface(FRAME_BUFFER, &uiSrcPitchBYTES);
for ( iX = 0; iX < 88; iX++ )
{
dY = dStartY;
for ( iY = 0; iY < 44; iY++ )
{
//OK, AVERAGE PIXELS
iSubX1 = (INT32)dX - WINDOW_SIZE;
iSubX2 = (INT32)dX + WINDOW_SIZE;
iSubY1 = (INT32)dY - WINDOW_SIZE;
iSubY2 = (INT32)dY + WINDOW_SIZE;
iCount = 0;
bR = bG = bB = 0;
for ( iWindowX = iSubX1; iWindowX < iSubX2; iWindowX++ )
{
for ( iWindowY = iSubY1; iWindowY < iSubY2; iWindowY++ )
{
if ( iWindowX >=0 && iWindowX < 640 && iWindowY >=0 && iWindowY < 320 )
{
s16BPPSrc = pSrcBuf[ ( iWindowY * (uiSrcPitchBYTES/2) ) + iWindowX ];
uiRGBColor = GetRGBColor( s16BPPSrc );
bR += SGPGetRValue( uiRGBColor );
bG += SGPGetGValue( uiRGBColor );
bB += SGPGetBValue( uiRGBColor );
// Average!
iCount++;
}
}
}
if ( iCount > 0 )
{
bAvR = bR / (UINT8)iCount;
bAvG = bG / (UINT8)iCount;
bAvB = bB / (UINT8)iCount;
sDest16BPPColor = Get16BPPColor( FROMRGB( bAvR, bAvG, bAvB ) );
}
//Write into dest!
pDestBuf[ ( iY * (uiDestPitchBYTES/2) ) + iX ] = sDest16BPPColor;
p24BitValues[ ( iY * (uiDestPitchBYTES/2) ) + iX ].r = (UINT8)bAvR;
p24BitValues[ ( iY * (uiDestPitchBYTES/2) ) + iX ].g = (UINT8)bAvG;
p24BitValues[ ( iY * (uiDestPitchBYTES/2) ) + iX ].b = (UINT8)bAvB;
//Increment
dY += gdYStep;
}
//Increment
dX += gdXStep;
}
UnLockVideoSurface(giMiniMap);
UnLockVideoSurface(FRAME_BUFFER);
// RENDER!
BltVideoSurface( FRAME_BUFFER, giMiniMap, 0, 20, 360, VS_BLT_FAST | VS_BLT_USECOLORKEY, NULL );
//QUantize!
pDataPtr = (UINT8*)LockVideoSurface(gi8BitMiniMap, &uiSrcPitchBYTES);
pDestBuf = (UINT16*)LockVideoSurface(FRAME_BUFFER, &uiDestPitchBYTES);
QuantizeImage( pDataPtr, p24BitDest, MINIMAP_X_SIZE, MINIMAP_Y_SIZE, pPalette );
SetVideoSurfacePalette( ghvSurface, pPalette );
// Blit!
Blt8BPPDataTo16BPPBuffer( pDestBuf, uiDestPitchBYTES, ghvSurface, pDataPtr, 300, 360);
// Write palette!
{
INT32 cnt;
INT32 sX = 0, sY = 420;
UINT16 usLineColor;
SetClippingRegionAndImageWidth( uiDestPitchBYTES, 0, 0, 640, 480 );
for ( cnt = 0; cnt < 256; cnt++ )
{
usLineColor = Get16BPPColor( FROMRGB( pPalette[ cnt ].peRed, pPalette[ cnt ].peGreen, pPalette[ cnt ].peBlue ) );
RectangleDraw( TRUE, sX, sY, sX, (INT16)( sY+10 ), usLineColor, (UINT8*)pDestBuf );
sX++;
RectangleDraw( TRUE, sX, sY, sX, (INT16)( sY+10 ), usLineColor, (UINT8*)pDestBuf );
sX++;
}
}
UnLockVideoSurface(FRAME_BUFFER);
// Remove extension
for ( cnt = strlen( zFilename )-1; cnt >=0; cnt-- )
{
if ( zFilename[ cnt ] == '.' )
{
zFilename[ cnt ] = '\0';
}
}
sprintf( (char *)zFilename2, "RADARMAPS\\%s.STI", zFilename );
WriteSTIFile( (INT8 *)pDataPtr, pPalette, MINIMAP_X_SIZE, MINIMAP_Y_SIZE, (STR) zFilename2, CONVERT_ETRLE_COMPRESS, 0 );
UnLockVideoSurface(gi8BitMiniMap);
SetFont( TINYFONT1 );
SetFontBackground( FONT_MCOLOR_BLACK );
SetFontForeground( FONT_MCOLOR_DKGRAY );
mprintf( 10, 340, L"Writing radar image %S", zFilename2 );
mprintf( 10, 350, L"Using tileset %s", gTilesets[ giCurrentTilesetID ].zName );
InvalidateScreen( );
while (DequeueEvent(&InputEvent) == TRUE)
{
if ((InputEvent.usEvent == KEY_DOWN)&&(InputEvent.usParam == ESC))
{ // Exit the program
gfProgramIsRunning = FALSE;
}
}
// Set next
FListNode = FListNode->pNext;
sCurFile++;
return( MAPUTILITY_SCREEN );
}
UINT32 MapUtilScreenShutdown( )
{
return( TRUE );
}
#else //non-editor version
#include "types.h"
#include "screenids.h"
UINT32 MapUtilScreenInit( )
{
return( TRUE );
}
UINT32 MapUtilScreenHandle( )
{
//If this screen ever gets set, then this is a bad thing -- endless loop
return( ERROR_SCREEN );
}
UINT32 MapUtilScreenShutdown( )
{
return( TRUE );
}
#endif
+705
View File
@@ -0,0 +1,705 @@
#ifdef PRECOMPILEDHEADERS
#include "Utils All.h"
#else
#include "MercTextBox.h"
#include "WCheck.h"
#include "renderworld.h"
#include "Font Control.h"
#include "Utilities.h"
#include "WordWrap.h"
#include "vobject_blitters.h"
#include "Render Dirty.h"
#include "Message.h"
#endif
#define TEXT_POPUP_WINDOW_TEXT_OFFSET_X 8
#define TEXT_POPUP_WINDOW_TEXT_OFFSET_Y 8
#define TEXT_POPUP_STRING_WIDTH 296
#define TEXT_POPUP_GAP_BN_LINES 10
#define TEXT_POPUP_FONT FONT12ARIAL
#define TEXT_POPUP_COLOR FONT_MCOLOR_WHITE
#define MERC_TEXT_FONT FONT12ARIAL
#define MERC_TEXT_COLOR FONT_MCOLOR_WHITE
#define MERC_TEXT_MIN_WIDTH 10
#define MERC_TEXT_POPUP_WINDOW_TEXT_OFFSET_X 10
#define MERC_TEXT_POPUP_WINDOW_TEXT_OFFSET_Y 10
#define MERC_BACKGROUND_WIDTH 350
#define MERC_BACKGROUND_HEIGHT 200
// the max number of pop up boxes availiable to user
#define MAX_NUMBER_OF_POPUP_BOXES 10
// attempt to add box to pop up box list
INT32 AddPopUpBoxToList( MercPopUpBox *pPopUpTextBox );
// grab box with this id value
MercPopUpBox * GetPopUpBoxIndex( INT32 iId );
// both of the below are index by the enum for thier types - background and border in
// MercTextBox.h
// filenames for border popup .sti's
STR8 zMercBorderPopupFilenames[ ] = {
"INTERFACE\\TactPopUp.sti",
"INTERFACE\\TactRedPopUp.sti",
"INTERFACE\\TactBluePopUp.sti",
"INTERFACE\\TactPopUpMain.sti",
"INTERFACE\\LaptopPopup.sti",
};
// filenames for background popup .pcx's
STR8 zMercBackgroundPopupFilenames[ ] = {
"INTERFACE\\TactPopupBackground.pcx",
"INTERFACE\\TactPopupWhiteBackground.pcx",
"INTERFACE\\TactPopupGreyBackground.pcx",
"INTERFACE\\TactPopupBackgroundMain.pcx",
"INTERFACE\\LaptopPopupBackground.pcx",
"INTERFACE\\imp_popup_background.pcx",
};
// the pop up box structure
MercPopUpBox gBasicPopUpTextBox;
// the current pop up box
MercPopUpBox *gPopUpTextBox = NULL;
// the old one
MercPopUpBox *gOldPopUpTextBox = NULL;
// the list of boxes
MercPopUpBox *gpPopUpBoxList[ MAX_NUMBER_OF_POPUP_BOXES ];
// the flags
UINT32 guiFlags = 0;
UINT32 guiBoxIcons;
UINT32 guiSkullIcons;
BOOLEAN SetCurrentPopUpBox( UINT32 uiId )
{
// given id of the box, find it in the list and set to current
//make sure the box id is valid
if( uiId == (UINT32) -1 )
{
//ScreenMsg( FONT_MCOLOR_WHITE, MSG_BETAVERSION, L"Error: Trying to set Current Popup Box using -1 as an ID" );
return( FALSE );
}
// see if box inited
if( gpPopUpBoxList[ uiId ] != NULL )
{
gPopUpTextBox = gpPopUpBoxList[ uiId ];
return( TRUE );
}
return ( FALSE );
}
BOOLEAN OverrideMercPopupBox( MercPopUpBox *pMercBox )
{
// store old box and set current this passed one
gOldPopUpTextBox = gPopUpTextBox;
gPopUpTextBox = pMercBox;
return( TRUE );
}
BOOLEAN ResetOverrideMercPopupBox( )
{
gPopUpTextBox = gOldPopUpTextBox;
return( TRUE );
}
BOOLEAN InitMercPopupBox( )
{
INT32 iCounter = 0;
VOBJECT_DESC VObjectDesc;
// init the pop up box list
for( iCounter = 0; iCounter < MAX_NUMBER_OF_POPUP_BOXES; iCounter++ )
{
// set ptr to null
gpPopUpBoxList[ iCounter ] = NULL;
}
// LOAD STOP ICON...
VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE;
FilenameForBPP("INTERFACE\\msgboxicons.sti", VObjectDesc.ImageFile);
if( !AddVideoObject( &VObjectDesc, &guiBoxIcons ) )
AssertMsg(0, "Missing INTERFACE\\msgboxicons.sti" );
// LOAD SKULL ICON...
VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE;
FilenameForBPP("INTERFACE\\msgboxiconskull.sti", VObjectDesc.ImageFile);
if( !AddVideoObject( &VObjectDesc, &guiSkullIcons ) )
AssertMsg(0, "Missing INTERFACE\\msgboxiconskull.sti" );
return( TRUE );
}
BOOLEAN ShutDownPopUpBoxes( )
{
INT32 iCounter = 0;
for( iCounter = 0; iCounter < MAX_NUMBER_OF_POPUP_BOXES ; iCounter++ )
{
// now attempt to remove this box
RemoveMercPopupBoxFromIndex( iCounter );
}
return( TRUE );
}
//Pass in the background index, and pointers to the font and shadow color
void GetMercPopupBoxFontColor( UINT8 ubBackgroundIndex, UINT8 *pubFontColor, UINT8 *pubFontShadowColor);
// Tactical Popup
BOOLEAN LoadTextMercPopupImages( UINT8 ubBackgroundIndex, UINT8 ubBorderIndex)
{
VSURFACE_DESC vs_desc;
VOBJECT_DESC VObjectDesc;
// this function will load the graphics associated with the background and border index values
// the background
vs_desc.fCreateFlags = VSURFACE_CREATE_FROMFILE | VSURFACE_SYSTEM_MEM_USAGE;
strcpy(vs_desc.ImageFile, zMercBackgroundPopupFilenames [ ubBackgroundIndex ]);
CHECKF(AddVideoSurface(&vs_desc, &gPopUpTextBox->uiMercTextPopUpBackground));
// border
VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE;
FilenameForBPP( zMercBorderPopupFilenames[ ubBorderIndex ], VObjectDesc.ImageFile );
CHECKF( AddVideoObject( &VObjectDesc, &gPopUpTextBox->uiMercTextPopUpBorder ) );
gPopUpTextBox->fMercTextPopupInitialized = TRUE;
// so far so good, return successful
gPopUpTextBox->ubBackgroundIndex = ubBackgroundIndex;
gPopUpTextBox->ubBorderIndex = ubBorderIndex;
return( TRUE );
}
void RemoveTextMercPopupImages( )
{
//this procedure will remove the background and border video surface/object from the indecies
if( gPopUpTextBox )
{
if( gPopUpTextBox->fMercTextPopupInitialized )
{
// the background
DeleteVideoSurfaceFromIndex( gPopUpTextBox->uiMercTextPopUpBackground );
// the border
DeleteVideoObjectFromIndex( gPopUpTextBox->uiMercTextPopUpBorder );
gPopUpTextBox->fMercTextPopupInitialized = FALSE;
}
}
// done
return;
}
BOOLEAN RenderMercPopUpBoxFromIndex( INT32 iBoxId, INT16 sDestX, INT16 sDestY, UINT32 uiBuffer )
{
// set the current box
if( SetCurrentPopUpBox( iBoxId ) == FALSE )
{
return ( FALSE );
}
// now attempt to render the box
return( RenderMercPopupBox( sDestX, sDestY, uiBuffer ) );
}
BOOLEAN RenderMercPopupBox(INT16 sDestX, INT16 sDestY, UINT32 uiBuffer )
{
// UINT32 uiDestPitchBYTES;
// UINT32 uiSrcPitchBYTES;
// UINT16 *pDestBuf;
// UINT16 *pSrcBuf;
// will render/transfer the image from the buffer in the data structure to the buffer specified by user
BOOLEAN fReturnValue = TRUE;
// grab the destination buffer
// pDestBuf = ( UINT16* )LockVideoSurface( uiBuffer, &uiDestPitchBYTES );
// now lock it
// pSrcBuf = ( UINT16* )LockVideoSurface( gPopUpTextBox->uiSourceBufferIndex, &uiSrcPitchBYTES);
//check to see if we are wanting to blit a transparent background
if ( gPopUpTextBox->uiFlags & MERC_POPUP_PREPARE_FLAGS_TRANS_BACK )
BltVideoSurface( uiBuffer, gPopUpTextBox->uiSourceBufferIndex, 0, sDestX, sDestY, VS_BLT_FAST | VS_BLT_USECOLORKEY, NULL );
else
BltVideoSurface( uiBuffer, gPopUpTextBox->uiSourceBufferIndex, 0, sDestX, sDestY, VS_BLT_FAST, NULL );
// blt, and grab return value
// fReturnValue = Blt16BPPTo16BPP(pDestBuf, uiDestPitchBYTES, pSrcBuf, uiSrcPitchBYTES, sDestX, sDestY, 0, 0, gPopUpTextBox->sWidth, gPopUpTextBox->sHeight);
//Invalidate!
if ( uiBuffer == FRAME_BUFFER )
{
InvalidateRegion( sDestX, sDestY, (INT16)( sDestX + gPopUpTextBox->sWidth ), (INT16)( sDestY + gPopUpTextBox->sHeight ) );
}
// unlock the video surfaces
// source
// UnLockVideoSurface( gPopUpTextBox->uiSourceBufferIndex );
// destination
// UnLockVideoSurface( uiBuffer );
// return success or failure
return fReturnValue;
}
INT32 AddPopUpBoxToList( MercPopUpBox *pPopUpTextBox )
{
INT32 iCounter = 0;
// make sure is a valid box
if( pPopUpTextBox == NULL )
{
return ( -1 );
}
// attempt to add box to list
for( iCounter = 0; iCounter < MAX_NUMBER_OF_POPUP_BOXES; iCounter++ )
{
if( gpPopUpBoxList[ iCounter ] == NULL )
{
// found a spot, inset
gpPopUpBoxList[ iCounter ] = pPopUpTextBox;
// set as current
SetCurrentPopUpBox( iCounter );
// return index value
return( iCounter );
}
}
// return failure
return( -1 );
}
// get box with this id
MercPopUpBox * GetPopUpBoxIndex( INT32 iId )
{
return( gpPopUpBoxList[ iId ] );
}
INT32 PrepareMercPopupBox( INT32 iBoxId, UINT8 ubBackgroundIndex, UINT8 ubBorderIndex, STR16 pString,
UINT16 usWidth, UINT16 usMarginX, UINT16 usMarginTopY, UINT16 usMarginBottomY,
UINT16 *pActualWidth, UINT16 *pActualHeight)
{
UINT16 usNumberVerticalPixels, usNumberOfLines;
UINT16 usTextWidth, usHeight;
UINT16 i;
HVOBJECT hImageHandle;
UINT16 usPosY, usPosX;
VSURFACE_DESC vs_desc;
UINT16 usStringPixLength;
SGPRect DestRect;
HVSURFACE hSrcVSurface;
UINT32 uiDestPitchBYTES;
UINT32 uiSrcPitchBYTES;
UINT16 *pDestBuf;
UINT8 *pSrcBuf;
UINT8 ubFontColor, ubFontShadowColor;
UINT16 usColorVal;
UINT16 usLoopEnd;
INT16 sDispTextXPos;
MercPopUpBox *pPopUpTextBox = NULL;
if( usWidth >= SCREEN_WIDTH )
return( -1 );
if( usWidth <= MERC_TEXT_MIN_WIDTH )
usWidth = MERC_TEXT_MIN_WIDTH;
// check id value, if -1, box has not been inited yet
if( iBoxId == -1 )
{
// no box yet
// create box
pPopUpTextBox = (MercPopUpBox *) MemAlloc( sizeof( MercPopUpBox ) );
// copy over ptr
gPopUpTextBox = pPopUpTextBox;
// Load appropriate images
if( LoadTextMercPopupImages( ubBackgroundIndex, ubBorderIndex ) == FALSE )
{
MemFree( pPopUpTextBox );
return( -1 );
}
}
else
{
// has been created already,
// Check if these images are different
// grab box
pPopUpTextBox = GetPopUpBoxIndex( iBoxId );
// box has valid id and no instance?..error
Assert( pPopUpTextBox );
// copy over ptr
gPopUpTextBox = pPopUpTextBox;
if ( ubBackgroundIndex != pPopUpTextBox->ubBackgroundIndex || ubBorderIndex != pPopUpTextBox->ubBorderIndex || !pPopUpTextBox->fMercTextPopupInitialized)
{
//Remove old, set new
RemoveTextMercPopupImages( );
if( LoadTextMercPopupImages( ubBackgroundIndex, ubBorderIndex ) == FALSE )
{
return( -1 );
}
}
}
gPopUpTextBox->uiFlags = guiFlags;
// reset flags
guiFlags = 0;
usStringPixLength = WFStringPixLength( (UINT16 *) pString, TEXT_POPUP_FONT);
if( usStringPixLength < ( usWidth - ( MERC_TEXT_POPUP_WINDOW_TEXT_OFFSET_X ) * 2 ) )
{
usWidth = usStringPixLength + MERC_TEXT_POPUP_WINDOW_TEXT_OFFSET_X * 2;
usTextWidth = usWidth - ( MERC_TEXT_POPUP_WINDOW_TEXT_OFFSET_X ) * 2 + 1;
}
else
{
usTextWidth = usWidth - ( MERC_TEXT_POPUP_WINDOW_TEXT_OFFSET_X ) * 2 + 1 - usMarginX;
}
usNumberVerticalPixels = IanWrappedStringHeight(0,0, usTextWidth, 2, TEXT_POPUP_FONT, MERC_TEXT_COLOR, (STR16) pString, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED);
usNumberOfLines = usNumberVerticalPixels / TEXT_POPUP_GAP_BN_LINES;
usHeight = usNumberVerticalPixels + MERC_TEXT_POPUP_WINDOW_TEXT_OFFSET_X * 2;
// Add height for margins
usHeight += usMarginTopY + usMarginBottomY;
// Add width for margins
usWidth += (usMarginX*2);
// Add width for iconic...
if ( ( pPopUpTextBox->uiFlags & ( MERC_POPUP_PREPARE_FLAGS_STOPICON | MERC_POPUP_PREPARE_FLAGS_SKULLICON ) ) )
{
// Make minimun height for box...
if ( usHeight < 45 )
{
usHeight = 45;
}
usWidth += 35;
}
if( usWidth >= MERC_BACKGROUND_WIDTH )
usWidth = MERC_BACKGROUND_WIDTH-1;
//make sure the area isnt bigger then the background texture
if( ( usWidth >= MERC_BACKGROUND_WIDTH ) || usHeight >= MERC_BACKGROUND_HEIGHT)
{
if( iBoxId == -1 )
{
MemFree( pPopUpTextBox );
}
return( -1 );
}
// Create a background video surface to blt the face onto
memset( &vs_desc, 0, sizeof( VSURFACE_DESC ) );
vs_desc.fCreateFlags = VSURFACE_CREATE_DEFAULT | VSURFACE_SYSTEM_MEM_USAGE;
vs_desc.usWidth = usWidth;
vs_desc.usHeight = usHeight;
vs_desc.ubBitDepth = 16;
CHECKF( AddVideoSurface( &vs_desc, &pPopUpTextBox->uiSourceBufferIndex) );
pPopUpTextBox->fMercTextPopupSurfaceInitialized = TRUE;
pPopUpTextBox->sWidth = usWidth;
pPopUpTextBox->sHeight = usHeight;
*pActualWidth = usWidth;
*pActualHeight = usHeight;
DestRect.iLeft = 0;
DestRect.iTop = 0;
DestRect.iRight = DestRect.iLeft + usWidth;
DestRect.iBottom = DestRect.iTop + usHeight;
if ( pPopUpTextBox->uiFlags & MERC_POPUP_PREPARE_FLAGS_TRANS_BACK )
{
// Zero with yellow,
// Set source transparcenty
SetVideoSurfaceTransparency( pPopUpTextBox->uiSourceBufferIndex, FROMRGB( 255, 255, 0 ) );
pDestBuf = (UINT16*)LockVideoSurface( pPopUpTextBox->uiSourceBufferIndex, &uiDestPitchBYTES);
usColorVal = Get16BPPColor( FROMRGB( 255, 255, 0 ) );
usLoopEnd = ( usWidth * usHeight );
for ( i = 0; i <usLoopEnd; i++ )
{
pDestBuf[ i ] = usColorVal;
}
UnLockVideoSurface(pPopUpTextBox->uiSourceBufferIndex);
}
else
{
if( !GetVideoSurface( &hSrcVSurface, pPopUpTextBox->uiMercTextPopUpBackground) )
{
AssertMsg( 0, String( "Failed to GetVideoSurface for PrepareMercPopupBox. VSurfaceID: %d",
pPopUpTextBox->uiMercTextPopUpBackground ) );
}
pDestBuf = (UINT16*)LockVideoSurface( pPopUpTextBox->uiSourceBufferIndex, &uiDestPitchBYTES);
pSrcBuf = LockVideoSurface( pPopUpTextBox->uiMercTextPopUpBackground, &uiSrcPitchBYTES);
Blt8BPPDataSubTo16BPPBuffer( pDestBuf, uiDestPitchBYTES, hSrcVSurface, pSrcBuf,uiSrcPitchBYTES,0,0, &DestRect);
UnLockVideoSurface( pPopUpTextBox->uiMercTextPopUpBackground);
UnLockVideoSurface(pPopUpTextBox->uiSourceBufferIndex);
}
GetVideoObject(&hImageHandle, pPopUpTextBox->uiMercTextPopUpBorder );
usPosX = usPosY = 0;
//blit top row of images
for(i=TEXT_POPUP_GAP_BN_LINES; i< usWidth-TEXT_POPUP_GAP_BN_LINES; i+=TEXT_POPUP_GAP_BN_LINES)
{
//TOP ROW
BltVideoObject(pPopUpTextBox->uiSourceBufferIndex, hImageHandle, 1,i, usPosY, VO_BLT_SRCTRANSPARENCY,NULL);
//BOTTOM ROW
BltVideoObject(pPopUpTextBox->uiSourceBufferIndex, hImageHandle, 6,i, usHeight - TEXT_POPUP_GAP_BN_LINES+6, VO_BLT_SRCTRANSPARENCY,NULL);
}
//blit the left and right row of images
usPosX = 0;
for(i=TEXT_POPUP_GAP_BN_LINES; i< usHeight-TEXT_POPUP_GAP_BN_LINES; i+=TEXT_POPUP_GAP_BN_LINES)
{
BltVideoObject(pPopUpTextBox->uiSourceBufferIndex, hImageHandle, 3,usPosX, i, VO_BLT_SRCTRANSPARENCY,NULL);
BltVideoObject(pPopUpTextBox->uiSourceBufferIndex, hImageHandle, 4,usPosX+usWidth-4, i, VO_BLT_SRCTRANSPARENCY,NULL);
}
//blt the corner images for the row
//top left
BltVideoObject(pPopUpTextBox->uiSourceBufferIndex, hImageHandle, 0, 0, usPosY, VO_BLT_SRCTRANSPARENCY,NULL);
//top right
BltVideoObject(pPopUpTextBox->uiSourceBufferIndex, hImageHandle, 2, usWidth-TEXT_POPUP_GAP_BN_LINES, usPosY, VO_BLT_SRCTRANSPARENCY,NULL);
//bottom left
BltVideoObject(pPopUpTextBox->uiSourceBufferIndex, hImageHandle, 5, 0, usHeight-TEXT_POPUP_GAP_BN_LINES, VO_BLT_SRCTRANSPARENCY,NULL);
//bottom right
BltVideoObject(pPopUpTextBox->uiSourceBufferIndex, hImageHandle, 7, usWidth-TEXT_POPUP_GAP_BN_LINES, usHeight-TEXT_POPUP_GAP_BN_LINES, VO_BLT_SRCTRANSPARENCY,NULL);
// Icon if ness....
if ( pPopUpTextBox->uiFlags & MERC_POPUP_PREPARE_FLAGS_STOPICON )
{
BltVideoObjectFromIndex( pPopUpTextBox->uiSourceBufferIndex, guiBoxIcons, 0, 5, 4, VO_BLT_SRCTRANSPARENCY,NULL);
}
if ( pPopUpTextBox->uiFlags & MERC_POPUP_PREPARE_FLAGS_SKULLICON )
{
BltVideoObjectFromIndex( pPopUpTextBox->uiSourceBufferIndex, guiSkullIcons, 0, 9, 4, VO_BLT_SRCTRANSPARENCY,NULL);
}
//Get the font and shadow colors
GetMercPopupBoxFontColor( ubBackgroundIndex, &ubFontColor, &ubFontShadowColor );
SetFontShadow( ubFontShadowColor );
SetFontDestBuffer( pPopUpTextBox->uiSourceBufferIndex, 0, 0, usWidth, usHeight, FALSE );
//Display the text
sDispTextXPos = (INT16)(( MERC_TEXT_POPUP_WINDOW_TEXT_OFFSET_X + usMarginX ));
if ( pPopUpTextBox->uiFlags & ( MERC_POPUP_PREPARE_FLAGS_STOPICON | MERC_POPUP_PREPARE_FLAGS_SKULLICON ) )
{
sDispTextXPos += 30;
}
//if language represents words with a single char
#ifdef SINGLE_CHAR_WORDS
{
//Enable the use of single word wordwrap
if( gfUseWinFonts )
{
UseSingleCharWordsForWordWrap( TRUE );
}
//Display the text
DisplayWrappedString( sDispTextXPos, (INT16)(( MERC_TEXT_POPUP_WINDOW_TEXT_OFFSET_Y + usMarginTopY ) ), usTextWidth, 2, MERC_TEXT_FONT, ubFontColor, pString, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED);
//Disable the use of single word wordwrap
UseSingleCharWordsForWordWrap( FALSE );
}
#else
{
//Display the text
DisplayWrappedString( sDispTextXPos, (INT16)(( MERC_TEXT_POPUP_WINDOW_TEXT_OFFSET_Y + usMarginTopY ) ), usTextWidth, 2, MERC_TEXT_FONT, ubFontColor, pString, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED);
}
#endif
SetFontDestBuffer( FRAME_BUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, FALSE );
SetFontShadow(DEFAULT_SHADOW);
if( iBoxId == -1 )
{
// now return attemp to add to pop up box list, if successful will return index
return( AddPopUpBoxToList( pPopUpTextBox ) );
}
else
{
// set as current box
SetCurrentPopUpBox( iBoxId );
return( iBoxId );
}
}
//Deletes the surface thats contains the border, background and the text.
BOOLEAN RemoveMercPopupBox()
{
INT32 iCounter = 0;
// make sure the current box does in fact exist
if( gPopUpTextBox == NULL )
{
// failed..
return( FALSE );
}
// now check to see if inited...
if( gPopUpTextBox->fMercTextPopupSurfaceInitialized )
{
// now find this box in the list
for( iCounter = 0; iCounter < MAX_NUMBER_OF_POPUP_BOXES; iCounter++ )
{
if( gpPopUpBoxList[ iCounter ] == gPopUpTextBox )
{
gpPopUpBoxList[ iCounter ] = NULL;
iCounter = MAX_NUMBER_OF_POPUP_BOXES;
}
}
// yep, get rid of the bloody...
DeleteVideoSurfaceFromIndex(gPopUpTextBox->uiSourceBufferIndex);
//DEF Added 5/26
//Delete the background and the border
RemoveTextMercPopupImages( );
MemFree( gPopUpTextBox );
// reset current ptr
gPopUpTextBox = NULL;
}
return(TRUE);
}
BOOLEAN RemoveMercPopupBoxFromIndex( UINT32 uiId )
{
// find this box, set it to current, and delete it
if( SetCurrentPopUpBox( uiId ) == FALSE )
{
// failed
return( FALSE );
}
// now try to remove it
return( RemoveMercPopupBox( ) );
}
//Pass in the background index, and pointers to the font and shadow color
void GetMercPopupBoxFontColor( UINT8 ubBackgroundIndex, UINT8 *pubFontColor, UINT8 *pubFontShadowColor)
{
switch( ubBackgroundIndex )
{
case BASIC_MERC_POPUP_BACKGROUND:
*pubFontColor = TEXT_POPUP_COLOR;
*pubFontShadowColor = DEFAULT_SHADOW;
break;
case WHITE_MERC_POPUP_BACKGROUND:
*pubFontColor = 2;
*pubFontShadowColor = FONT_MCOLOR_WHITE;
break;
case GREY_MERC_POPUP_BACKGROUND:
*pubFontColor = 2;
*pubFontShadowColor = NO_SHADOW;
break;
case LAPTOP_POPUP_BACKGROUND:
*pubFontColor = TEXT_POPUP_COLOR;
*pubFontShadowColor = DEFAULT_SHADOW;
break;
default:
*pubFontColor = TEXT_POPUP_COLOR;
*pubFontShadowColor = DEFAULT_SHADOW;
break;
}
}
BOOLEAN SetPrepareMercPopupFlags( UINT32 uiFlags )
{
guiFlags |= uiFlags;
return( TRUE );
}
BOOLEAN SetPrepareMercPopUpFlagsFromIndex( UINT32 uiFlags, UINT32 uiId )
{
// find this box, set it to current, and delete it
if( SetCurrentPopUpBox( uiId ) == FALSE )
{
// failed
return( FALSE );
}
// now try to remove it
return( SetPrepareMercPopupFlags( uiFlags ) );
}
+75
View File
@@ -0,0 +1,75 @@
#ifndef __MERCTEXTBOX_H_
#define __MERCTEXTBOX_H_
#include "Types.h"
#define MERC_POPUP_PREPARE_FLAGS_TRANS_BACK 0x00000001
#define MERC_POPUP_PREPARE_FLAGS_MARGINS 0x00000002
#define MERC_POPUP_PREPARE_FLAGS_STOPICON 0x00000004
#define MERC_POPUP_PREPARE_FLAGS_SKULLICON 0x00000008
BOOLEAN InitMercPopupBox( );
// create a pop up box if needed, return id of box..a -1 means couldn't be added
INT32 PrepareMercPopupBox( INT32 iBoxId, UINT8 ubBackgroundIndex, UINT8 ubBorderIndex, STR16 pString, UINT16 usWidth, UINT16 usMarginX, UINT16 usMarginTopY, UINT16 usMarginBottomY, UINT16 *pActualWidth, UINT16 *pActualHeight);
// remove the current box
BOOLEAN RemoveMercPopupBox();
// remove this box from the index
BOOLEAN RemoveMercPopupBoxFromIndex( UINT32 uiId );
// render the current pop up box
BOOLEAN RenderMercPopupBox(INT16 sDestX, INT16 sDestY, UINT32 uiBuffer );
// render pop up box with this index value
BOOLEAN RenderMercPopUpBoxFromIndex( INT32 iBoxId, INT16 sDestX, INT16 sDestY, UINT32 uiBuffer );
void RemoveTextMercPopupImages( );
typedef struct {
UINT32 uiSourceBufferIndex;
UINT16 sWidth;
UINT16 sHeight;
UINT8 ubBackgroundIndex;
UINT8 ubBorderIndex;
UINT32 uiMercTextPopUpBackground;
UINT32 uiMercTextPopUpBorder;
BOOLEAN fMercTextPopupInitialized;
BOOLEAN fMercTextPopupSurfaceInitialized;
UINT32 uiFlags;
} MercPopUpBox;
BOOLEAN OverrideMercPopupBox( MercPopUpBox *pMercBox );
BOOLEAN ResetOverrideMercPopupBox( );
BOOLEAN SetPrepareMercPopupFlags( UINT32 uiFlags );
// background enumeration
enum{
BASIC_MERC_POPUP_BACKGROUND = 0,
WHITE_MERC_POPUP_BACKGROUND,
GREY_MERC_POPUP_BACKGROUND,
DIALOG_MERC_POPUP_BACKGROUND,
LAPTOP_POPUP_BACKGROUND,
IMP_POPUP_BACKGROUND,
};
// border enumeration
enum{
BASIC_MERC_POPUP_BORDER =0,
RED_MERC_POPUP_BORDER,
BLUE_MERC_POPUP_BORDER,
DIALOG_MERC_POPUP_BORDER,
LAPTOP_POP_BORDER
};
#endif
+359
View File
@@ -0,0 +1,359 @@
#include "Utils All.h"
#include "Language Defines.h"
BOOLEAN GetMLGFilename( SGPFILENAME filename, UINT16 usMLGGraphicID )
{
#if defined( ENGLISH ) || defined( TAIWANESE ) || defined( FRENCH )
switch( usMLGGraphicID )
{
case MLG_AIMSYMBOL:
sprintf( filename, "LAPTOP\\AimSymbol.sti" );
return TRUE;
case MLG_BOBBYNAME:
sprintf( filename, "LAPTOP\\BobbyName.sti" );
return TRUE;
case MLG_BOBBYRAYAD21:
sprintf( filename, "LAPTOP\\BobbyRayAd_21.sti" );
return TRUE;
case MLG_BOBBYRAYLINK:
sprintf( filename, "LAPTOP\\BobbyRayLink.sti" );
return TRUE;
case MLG_CLOSED:
sprintf( filename, "LAPTOP\\Closed.sti" );
return TRUE;
case MLG_CONFIRMORDER:
sprintf( filename, "LAPTOP\\ConfirmOrder.sti" );
return TRUE;
case MLG_DESKTOP:
sprintf( filename, "LAPTOP\\desktop.pcx" );
return TRUE;
case MLG_FUNERALAD9:
sprintf( filename, "LAPTOP\\FuneralAd_9.sti" );
return TRUE;
case MLG_GOLDPIECEBUTTONS:
sprintf( filename, "INTERFACE\\goldpiecebuttons.sti" );
return TRUE;
case MLG_HISTORY:
sprintf( filename, "LAPTOP\\history.sti" );
return TRUE;
case MLG_INSURANCEAD10:
sprintf( filename, "LAPTOP\\insurancead_10.sti" );
return TRUE;
case MLG_INSURANCELINK:
sprintf( filename, "LAPTOP\\insurancelink.sti" );
return TRUE;
case MLG_INSURANCETITLE:
sprintf( filename, "LAPTOP\\largetitle.sti" );
return TRUE;
case MLG_LARGEFLORISTSYMBOL:
sprintf( filename, "LAPTOP\\LargeSymbol.sti" );
return TRUE;
case MLG_SMALLFLORISTSYMBOL:
sprintf( filename, "LAPTOP\\SmallSymbol.sti" );
return TRUE;
case MLG_MCGILLICUTTYS:
sprintf( filename, "LAPTOP\\McGillicuttys.sti" );
return TRUE;
case MLG_MORTUARY:
sprintf( filename, "LAPTOP\\Mortuary.sti" );
return TRUE;
case MLG_MORTUARYLINK:
sprintf( filename, "LAPTOP\\MortuaryLink.sti" );
return TRUE;
case MLG_ORDERGRID:
sprintf( filename, "LAPTOP\\OrderGrid.sti" );
return TRUE;
case MLG_PREBATTLEPANEL:
sprintf( filename, "INTERFACE\\PreBattlePanel.sti" );
return TRUE;
case MLG_SMALLTITLE:
sprintf( filename, "LAPTOP\\SmallTitle.sti" );
return TRUE;
case MLG_STATSBOX:
sprintf( filename, "LAPTOP\\StatsBox.sti" );
return TRUE;
case MLG_STOREPLAQUE:
sprintf( filename, "LAPTOP\\BobbyStorePlaque.sti" );
return TRUE;
case MLG_TITLETEXT:
sprintf( filename, "LOADSCREENS\\titletext.sti" );
return TRUE;
case MLG_TOALUMNI:
sprintf( filename, "LAPTOP\\ToAlumni.sti" );
return TRUE;
case MLG_TOMUGSHOTS:
sprintf( filename, "LAPTOP\\ToMugShots.sti" );
return TRUE;
case MLG_TOSTATS:
sprintf( filename, "LAPTOP\\ToStats.sti" );
return TRUE;
case MLG_WARNING:
sprintf( filename, "LAPTOP\\Warning.sti" );
return TRUE;
case MLG_YOURAD13:
sprintf( filename, "LAPTOP\\YourAd_13.sti" );
return TRUE;
case MLG_OPTIONHEADER:
sprintf( filename, "INTERFACE\\optionscreenaddons.sti" );
return TRUE;
case MLG_LOADSAVEHEADER:
sprintf( filename, "INTERFACE\\loadscreenaddons.sti" );
return TRUE;
case MLG_SPLASH:
sprintf( filename, "INTERFACE\\splash.sti" );
return TRUE;
case MLG_IMPSYMBOL:
sprintf( filename, "LAPTOP\\IMPSymbol.sti" );
return TRUE;
}
#elif defined( GERMAN )
switch( usMLGGraphicID )
{
case MLG_AIMSYMBOL:
//Same graphic (no translation needed)
sprintf( filename, "LAPTOP\\AimSymbol.sti" );
return TRUE;
case MLG_BOBBYNAME:
//Same graphic (no translation needed)
sprintf( filename, "LAPTOP\\BobbyName.sti" );
return TRUE;
case MLG_BOBBYRAYAD21:
//Same graphic (no translation needed)
sprintf( filename, "LAPTOP\\BobbyRayAd_21.sti" );
return TRUE;
case MLG_BOBBYRAYLINK:
sprintf( filename, "GERMAN\\BobbyRayLink_german.sti" );
return TRUE;
case MLG_CLOSED:
sprintf( filename, "GERMAN\\Closed_german.sti" );
return TRUE;
case MLG_CONFIRMORDER:
sprintf( filename, "GERMAN\\ConfirmOrder_german.sti" );
return TRUE;
case MLG_DESKTOP:
sprintf( filename, "GERMAN\\desktop_german.pcx" );
return TRUE;
case MLG_FUNERALAD9:
sprintf( filename, "GERMAN\\FuneralAd_12_german.sti" );
return TRUE;
case MLG_GOLDPIECEBUTTONS:
sprintf( filename, "GERMAN\\goldpiecebuttons_german.sti" );
return TRUE;
case MLG_HISTORY:
sprintf( filename, "GERMAN\\history_german.sti" );
return TRUE;
case MLG_IMPSYMBOL:
sprintf( filename, "German\\IMPSymbol_german.sti" );
return TRUE;
case MLG_INSURANCEAD10:
sprintf( filename, "GERMAN\\insurancead_10_german.sti" );
return TRUE;
case MLG_INSURANCELINK:
sprintf( filename, "GERMAN\\insurancelink_german.sti" );
return TRUE;
case MLG_INSURANCETITLE:
sprintf( filename, "GERMAN\\largetitle_german.sti" );
return TRUE;
case MLG_LARGEFLORISTSYMBOL:
sprintf( filename, "GERMAN\\LargeSymbol_german.sti" );
return TRUE;
case MLG_SMALLFLORISTSYMBOL:
sprintf( filename, "GERMAN\\SmallSymbol_german.sti" );
return TRUE;
case MLG_MCGILLICUTTYS:
sprintf( filename, "GERMAN\\McGillicuttys_german.sti" );
return TRUE;
case MLG_MORTUARY:
sprintf( filename, "GERMAN\\Mortuary_german.sti" );
return TRUE;
case MLG_MORTUARYLINK:
sprintf( filename, "GERMAN\\MortuaryLink_german.sti" );
return TRUE;
case MLG_PREBATTLEPANEL:
sprintf( filename, "GERMAN\\PreBattlePanel_german.sti" );
return TRUE;
case MLG_SMALLTITLE:
sprintf( filename, "GERMAN\\SmallTitle_german.sti" );
return TRUE;
case MLG_STATSBOX:
//Same file
sprintf( filename, "LAPTOP\\StatsBox.sti" );
return TRUE;
case MLG_STOREPLAQUE:
sprintf( filename, "GERMAN\\StorePlaque_german.sti" );
return TRUE;
case MLG_TITLETEXT:
sprintf( filename, "GERMAN\\titletext_german.sti" );
return TRUE;
case MLG_TOALUMNI:
sprintf( filename, "GERMAN\\ToAlumni_german.sti" );
return TRUE;
case MLG_TOMUGSHOTS:
sprintf( filename, "GERMAN\\ToMugShots_german.sti" );
return TRUE;
case MLG_TOSTATS:
sprintf( filename, "GERMAN\\ToStats_german.sti" );
return TRUE;
case MLG_WARNING:
sprintf( filename, "GERMAN\\Warning_german.sti" );
return TRUE;
case MLG_YOURAD13:
sprintf( filename, "GERMAN\\YourAd_13_german.sti" );
return TRUE;
case MLG_OPTIONHEADER:
sprintf( filename, "GERMAN\\optionscreenaddons_german.sti" );
return TRUE;
case MLG_LOADSAVEHEADER:
sprintf( filename, "GERMAN\\loadscreenaddons_german.sti" );
return TRUE;
case MLG_ORDERGRID:
//Same file
sprintf( filename, "LAPTOP\\OrderGrid.sti" );
return TRUE;
case MLG_SPLASH:
sprintf( filename, "German\\splash_german.sti" );
return TRUE;
}
#else
UINT8 zLanguage[64];
//The foreign language defined determines the name of the directory and filename.
//For example, the German version of:
//
// "LAPTOP\\IMPSymbol.sti"
//
// would become:
//
// "GERMAN\\IMPSymbol_German.sti"
#if defined( DUTCH )
sprintf( zLanguage, "DUTCH" );
#elif defined( FRENCH )
sprintf( zLanguage, "FRENCH" );
#elif defined( GERMAN )
sprintf( zLanguage, "GERMAN" );
#elif defined( ITALIAN )
sprintf( zLanguage, "ITALIAN" );
#elif defined( JAPANESE )
sprintf( zLanguage, "JAPANESE" );
#elif defined( KOREAN )
sprintf( zLanguage, "KOREAN" );
#elif defined( POLISH )
sprintf( zLanguage, "POLISH" );
#elif defined( RUSSIAN )
sprintf( zLanguage, "RUSSIAN" );
#elif defined( SPANISH )
sprintf( zLanguage, "SPANISH" );
#elif defined( TAIWANESE )
sprintf( zLanguage, "TAIWANESE" );
#endif
switch( usMLGGraphicID )
{
case MLG_AIMSYMBOL:
sprintf( filename, "%s\\AimSymbol_%s.sti", zLanguage, zLanguage );
return TRUE;
case MLG_BOBBYNAME:
sprintf( filename, "%s\\BobbyName_%s.sti", zLanguage, zLanguage );
return TRUE;
case MLG_BOBBYRAYAD21:
sprintf( filename, "%s\\BobbyRayAd_21_%s.sti", zLanguage, zLanguage );
return TRUE;
case MLG_BOBBYRAYLINK:
sprintf( filename, "%s\\BobbyRayLink_%s.sti", zLanguage, zLanguage );
return TRUE;
case MLG_CLOSED:
sprintf( filename, "%s\\Closed_%s.sti", zLanguage, zLanguage );
return TRUE;
case MLG_CONFIRMORDER:
sprintf( filename, "%s\\ConfirmOrder_%s.sti", zLanguage, zLanguage );
return TRUE;
case MLG_DESKTOP:
sprintf( filename, "%s\\desktop_%s.pcx", zLanguage, zLanguage );
return TRUE;
case MLG_FUNERALAD9:
sprintf( filename, "%s\\FuneralAd_9_%s.sti", zLanguage, zLanguage );
return TRUE;
case MLG_GOLDPIECEBUTTONS:
sprintf( filename, "%s\\goldpiecebuttons_%s.sti", zLanguage, zLanguage );
return TRUE;
case MLG_HISTORY:
sprintf( filename, "%s\\history_%s.sti", zLanguage, zLanguage );
return TRUE;
case MLG_INSURANCEAD10:
sprintf( filename, "%s\\insurancead_10_%s.sti", zLanguage, zLanguage );
return TRUE;
case MLG_INSURANCELINK:
sprintf( filename, "%s\\insurancelink_%s.sti", zLanguage, zLanguage );
return TRUE;
case MLG_INSURANCETITLE:
sprintf( filename, "%s\\largetitle_%s.sti", zLanguage, zLanguage );
return TRUE;
case MLG_LARGEFLORISTSYMBOL:
sprintf( filename, "%s\\LargeSymbol_%s.sti", zLanguage, zLanguage );
return TRUE;
case MLG_ORDERGRID:
sprintf( filename, "%s\\OrderGrid_%s.sti", zLanguage, zLanguage );
return TRUE;
case MLG_SMALLFLORISTSYMBOL:
sprintf( filename, "%s\\SmallSymbol_%s.sti", zLanguage, zLanguage );
return TRUE;
case MLG_STATSBOX:
sprintf( filename, "%s\\StatsBox_%s.sti", zLanguage, zLanguage );
return TRUE;
case MLG_MCGILLICUTTYS:
sprintf( filename, "%s\\McGillicuttys_%s.sti", zLanguage, zLanguage );
return TRUE;
case MLG_MORTUARY:
sprintf( filename, "%s\\Mortuary_%s.sti", zLanguage, zLanguage );
return TRUE;
case MLG_MORTUARYLINK:
sprintf( filename, "%s\\MortuaryLink_%s.sti", zLanguage, zLanguage );
return TRUE;
case MLG_PREBATTLEPANEL:
sprintf( filename, "%s\\PreBattlePanel_%s.sti", zLanguage, zLanguage );
return TRUE;
case MLG_SMALLTITLE:
sprintf( filename, "%s\\SmallTitle_%s.sti", zLanguage, zLanguage );
return TRUE;
case MLG_STOREPLAQUE:
sprintf( filename, "%s\\StorePlaque_%s.sti", zLanguage, zLanguage );
return TRUE;
case MLG_TITLETEXT:
sprintf( filename, "%s\\titletext_%s.sti", zLanguage, zLanguage );
return TRUE;
case MLG_TOALUMNI:
sprintf( filename, "%s\\ToAlumni_%s.sti", zLanguage, zLanguage );
return TRUE;
case MLG_TOMUGSHOTS:
sprintf( filename, "%s\\ToMugShots_%s.sti", zLanguage, zLanguage );
return TRUE;
case MLG_TOSTATS:
sprintf( filename, "%s\\ToStats_%s.sti", zLanguage, zLanguage );
return TRUE;
case MLG_WARNING:
sprintf( filename, "%s\\Warning_%s.sti", zLanguage, zLanguage );
return TRUE;
case MLG_YOURAD13:
sprintf( filename, "%s\\YourAd_13_%s.sti", zLanguage, zLanguage );
return TRUE;
case MLG_OPTIONHEADER:
sprintf( filename, "%s\\optionscreenaddons_%s.sti", zLanguage, zLanguage );
return TRUE;
case MLG_LOADSAVEHEADER:
sprintf( filename, "%s\\loadscreenaddons_%s.sti", zLanguage, zLanguage );
return TRUE;
case MLG_SPLASH:
sprintf( filename, "%s\\splash_%s.sti", zLanguage, zLanguage );
return TRUE;
case MLG_IMPSYMBOL:
sprintf( filename, "%s\\IMPSymbol_%s.sti", zLanguage, zLanguage );
return TRUE;
}
#endif
return FALSE;
}
+44
View File
@@ -0,0 +1,44 @@
#ifndef __MULTI_LANGUAGE_GRAPHIC_UTILS_H
#define __MULTI_LANGUAGE_GRAPHIC_UTILS_H
enum
{
MLG_AIMSYMBOL,
MLG_BOBBYNAME,
MLG_BOBBYRAYAD21,
MLG_BOBBYRAYLINK,
MLG_CLOSED,
MLG_CONFIRMORDER,
MLG_DESKTOP,
MLG_FUNERALAD9,
MLG_GOLDPIECEBUTTONS,
MLG_HISTORY,
MLG_IMPSYMBOL,
MLG_INSURANCEAD10,
MLG_INSURANCELINK,
MLG_INSURANCETITLE, //LargeTitle
MLG_LARGEFLORISTSYMBOL, //LargeSymbol
MLG_LOADSAVEHEADER, //LoadScreenAddOns
MLG_MCGILLICUTTYS,
MLG_MORTUARY,
MLG_MORTUARYLINK,
MLG_OPTIONHEADER, //OptionScreenAddOns
MLG_ORDERGRID,
MLG_PREBATTLEPANEL,
MLG_SECTORINVENTORY,
MLG_SMALLFLORISTSYMBOL, //SmallSymbol
MLG_SMALLTITLE,
MLG_SPLASH,
MLG_STATSBOX,
MLG_STOREPLAQUE,
MLG_TITLETEXT,
MLG_TOALUMNI,
MLG_TOMUGSHOTS,
MLG_TOSTATS,
MLG_WARNING,
MLG_YOURAD13,
};
BOOLEAN GetMLGFilename( SGPFILENAME filename, UINT16 usMLGGraphicID );
#endif
+159
View File
@@ -0,0 +1,159 @@
/*
MULTILINGUAL TEXT CODE GENERATOR
This code generator is used to conveniently compare the english master text file with another foreign language
such as German and verify that the appropriate language file is in perfect synch with the English. Verifying
that all of the strings have the correct order of printf format specifiers and the precise number. If
different, the errors are recorded via comments proceeding the string in question in the new file. For
simplicity, the German language will be used in examples throughout this documention. The comments will be
specially marked with "CONFLICT#xxx: error message" which can be searched for. The comment will report
the format specifiers used in the english version.
ASSUMPTIONS
- No functions exist in any of the master files
- Users don't use single strings using:
STR16 str[] = L"Single String";
Instead use:
STR16 str[] =
{
L"Single String";
}
- Users don't use comments containing the { character later followed by the L" token. The code generator
will mistaken that for a string.
- Users don't use nested braces (2D text arrays)
AUTHOR: Kris Morness
CREATED: Feb 16, 1999
*/
#ifdef _DEBUG
#include <stdio.h>
#include "types.h"
#include "Language Defines.h"
#include "debug.h"
#include "Fileman.h"
//Currently in JA2's _EnglishText, these tokens make up all of the
//format specifiers that are actually used. Feel free to add more,
//but make sure you change NUM_TOKENS accordingly. These tokens assume
//the previous character is a % character.
UINT8 SupportedTokens[] =
{
'd',
'c',
's',
'S',
'%',
};
#define NUM_TOKENS 5
enum
{
//look for { character followed by L" before } to upgrade to INSIDE_STRING
OUTSIDE_STRING_ARRAY,
//look for } character to downgrade to OUTSIDE_STRING_ARRAY
//look for L" characters to upgrade to INSIDE_STRING
INSIDE_STRING_ARRAY,
//look for " character to downgrade to INSIDE_STRING_ARRAY
INSIDE_STRING,
};
//Specifies where the master english file is located relative to the exe directory
#define LCG_WORKINGDIRECTORY "build\\utils"
#define LCG_ENGLISHMASTERFILE "_EnglishText.c"
//The commandline argument (add different one for each language supported
//***Only one can exist at a time and it is controlled by Language Defines.h )
#define LCG_COMMANDLINEARGUMENT "-GERMAN"
#define LCG_FOREIGNMASTERFILE "_GermanText.c"
#define LCG_FOREIGNNEWFILE "_NewGermanText.c"
//Given a file pointer, searches for the next DB string
UINT32 CountDoubleByteStringsInFile( UINT8 * filename );
//One function does it all. First looks for the cmd line arg, and if it matches
//the above define, searches for the files, and processes them automatically.
BOOLEAN ProcessIfMultilingualCmdLineArgDetected( UINT8 *str )
{
STRING512 ExecDir;
STRING512 CurrDir;
STRING512 Dir;
UINT32 uiEnglishStrings, uiForeignStrings;
//check if command line argument matches the LCG's
if( strcmp( (const char *)str, LCG_COMMANDLINEARGUMENT ) )
{ //string is different, so return
return FALSE;
}
//Record the exe directory
GetExecutableDirectory( ExecDir );
//Record the curr directory used (we will restore before leaving)
GetFileManCurrentDirectory( CurrDir );
//Build the working directory name
sprintf( Dir, "%s\\%s", ExecDir, LCG_WORKINGDIRECTORY );
//Set the working directory
if( !SetFileManCurrentDirectory( Dir ) )
{ //We failed meaning the directory name is incorrect or non-existant
AssertMsg( 0, "Failed to set directory location while attempting to activate multilingual text code generator." );
return FALSE;
}
//verify that all files exist
if( !FileExists( LCG_ENGLISHMASTERFILE ) )
{
AssertMsg( 0, "Failed to find master english file while attempting to activate multilingual text code generator." );
return FALSE;
}
if( !FileExists( LCG_FOREIGNMASTERFILE ) )
{
AssertMsg( 0, "Failed to find master foreign file while attempting to activate multilingual text code generator." );
return FALSE;
}
//ALL PRELIMINARY CHECKS HAVE SUCCEEDED.
//Begin file preparation checks...
//STEP1: Read the English master file and count the number of DB strings that exist
uiEnglishStrings = CountDoubleByteStringsInFile( (UINT8 *)LCG_ENGLISHMASTERFILE );
//STEP2: Read the Foreigh master file and count the number of DB strings that exist
uiForeignStrings = CountDoubleByteStringsInFile( (UINT8 *)LCG_FOREIGNMASTERFILE );
//Make sure they match, otherwise, we can't continue.
if( uiEnglishStrings != uiForeignStrings )
{
AssertMsg( 0, String( "Mismatch during LCG preparation: English DB strings: %d, Foreign DB strings: %d",
uiEnglishStrings, uiForeignStrings ) );
return FALSE;
}
//Mission complete! Reset the previously known directory, and return TRUE;
SetFileManCurrentDirectory( CurrDir );
return TRUE;
}
UINT32 CountDoubleByteStringsInFile( UINT8 * filename )
{
FILE *fp = NULL;
UINT32 uiNumStrings = 0;
//open file
fp = fopen( (const char *)filename, "r" );
if( !fp )
{
return 0;
}
fclose( fp );
return uiNumStrings;
}
#endif //_DEBUG
+12
View File
@@ -0,0 +1,12 @@
#ifdef _DEBUG
//If special command line argument is used, then the utility will kick in
//and activate the special code generator.
BOOLEAN ProcessIfMultilingualCmdLineArgDetected( UINT8 *str );
#else
//macro function out
#define ProcessIfMultilingualCmdLineArgDetected( a ) 0
#endif
+557
View File
@@ -0,0 +1,557 @@
#ifdef PRECOMPILEDHEADERS
#include "Utils All.h"
#else
#include "types.h"
#include "Music Control.h"
#include "soundman.h"
#include "Random.h"
#include "gamescreen.h"
#include "jascreens.h"
#include "Creature Spreading.h"
#include "soldier control.h"
#include "overhead.h"
#include "timer control.h"
#include "strategicmap.h"
#include "fade screen.h"
#endif
UINT32 uiMusicHandle=NO_SAMPLE;
UINT32 uiMusicVolume=50;
BOOLEAN fMusicPlaying=FALSE;
BOOLEAN fMusicFadingOut=FALSE;
BOOLEAN fMusicFadingIn=FALSE;
BOOLEAN gfMusicEnded = FALSE;
UINT8 gubMusicMode = 0;
UINT8 gubOldMusicMode = 0;
INT8 gbVictorySongCount = 0;
INT8 gbDeathSongCount = 0;
INT8 bNothingModeSong;
INT8 bEnemyModeSong;
INT8 bBattleModeSong;
INT8 gbFadeSpeed = 1;
CHAR8 *szMusicList[NUM_MUSIC]=
{
"MUSIC\\marimbad 2.wav",
"MUSIC\\menumix1.wav",
"MUSIC\\nothing A.wav",
"MUSIC\\nothing B.wav",
"MUSIC\\nothing C.wav",
"MUSIC\\nothing D.wav",
"MUSIC\\tensor A.wav",
"MUSIC\\tensor B.wav",
"MUSIC\\tensor C.wav",
"MUSIC\\triumph.wav",
"MUSIC\\death.wav",
"MUSIC\\battle A.wav",
"MUSIC\\tensor B.wav",
"MUSIC\\creepy.wav",
"MUSIC\\creature battle.wav",
};
BOOLEAN gfForceMusicToTense = FALSE;
BOOLEAN gfDontRestartSong = FALSE;
BOOLEAN StartMusicBasedOnMode( );
void DoneFadeOutDueToEndMusic( void );
extern void HandleEndDemoInCreatureLevel( );
BOOLEAN NoEnemiesInSight( )
{
SOLDIERTYPE *pSoldier;
INT32 cnt;
// Loop through our guys
// End the turn of player charactors
cnt = gTacticalStatus.Team[ gbPlayerNum ].bFirstID;
// look for all mercs on the same team,
for ( pSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ gbPlayerNum ].bLastID; cnt++, pSoldier++ )
{
if ( pSoldier->bActive && pSoldier->bLife >= OKLIFE )
{
if ( pSoldier->bOppCnt != 0 )
{
return( FALSE );
}
}
}
return( TRUE );
}
void MusicStopCallback( void *pData );
//********************************************************************************
// MusicPlay
//
// Starts up one of the tunes in the music list.
//
// Returns: TRUE if the music was started, FALSE if an error occurred
//
//********************************************************************************
BOOLEAN MusicPlay(UINT32 uiNum)
{
#ifndef WINDOWED_MODE
SOUNDPARMS spParms;
if(fMusicPlaying)
MusicStop();
memset(&spParms, 0xff, sizeof(SOUNDPARMS));
spParms.uiPriority=PRIORITY_MAX;
spParms.uiVolume=0;
spParms.EOSCallback = MusicStopCallback;
//DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "About to call SoundPlayStreamedFile" );
uiMusicHandle=SoundPlayStreamedFile(szMusicList[uiNum], &spParms);
if(uiMusicHandle!=SOUND_ERROR)
{
//DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String( "Music PLay %d %d", uiMusicHandle, gubMusicMode ) );
gfMusicEnded = FALSE;
fMusicPlaying=TRUE;
MusicFadeIn();
return(TRUE);
}
//DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String( "Music PLay %d %d", uiMusicHandle, gubMusicMode ) );
#endif
return(FALSE);
}
//********************************************************************************
// MusicSetVolume
//
// Sets the volume on the currently playing music.
//
// Returns: TRUE if the volume was set, FALSE if an error occurred
//
//********************************************************************************
BOOLEAN MusicSetVolume(UINT32 uiVolume)
{
INT32 uiOldMusicVolume = uiMusicVolume;
#ifndef WINDOWED_MODE
uiMusicVolume=__min(uiVolume, 127);
if(uiMusicHandle!=NO_SAMPLE)
{
// get volume and if 0 stop music!
if ( uiMusicVolume == 0 )
{
gfDontRestartSong = TRUE;
MusicStop( );
return( TRUE );
}
SoundSetVolume(uiMusicHandle, uiMusicVolume);
return(TRUE);
}
// If here, check if we need to re-start music
// Have we re-started?
if ( uiMusicVolume > 0 && uiOldMusicVolume == 0 )
{
StartMusicBasedOnMode( );
}
#endif
return(FALSE);
}
//********************************************************************************
// MusicGetVolume
//
// Gets the volume on the currently playing music.
//
// Returns: TRUE if the volume was set, FALSE if an error occurred
//
//********************************************************************************
UINT32 MusicGetVolume(void)
{
return(uiMusicVolume);
}
//********************************************************************************
// MusicStop
//
// Stops the currently playing music.
//
// Returns: TRUE if the music was stopped, FALSE if an error occurred
//
//********************************************************************************
BOOLEAN MusicStop(void)
{
#ifndef WINDOWED_MODE
if(uiMusicHandle!=NO_SAMPLE)
{
//DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String( "Music Stop %d %d", uiMusicHandle, gubMusicMode ) );
SoundStop(uiMusicHandle);
fMusicPlaying=FALSE;
uiMusicHandle = NO_SAMPLE;
return(TRUE);
}
//DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String( "Music Stop %d %d", uiMusicHandle, gubMusicMode ) );
#endif
return(FALSE);
}
//********************************************************************************
// MusicFadeOut
//
// Fades out the current song.
//
// Returns: TRUE if the music has begun fading, FALSE if an error occurred
//
//********************************************************************************
BOOLEAN MusicFadeOut(void)
{
if(uiMusicHandle!=NO_SAMPLE)
{
fMusicFadingOut=TRUE;
return(TRUE);
}
return(FALSE);
}
//********************************************************************************
// MusicFadeIn
//
// Fades in the current song.
//
// Returns: TRUE if the music has begun fading in, FALSE if an error occurred
//
//********************************************************************************
BOOLEAN MusicFadeIn(void)
{
if(uiMusicHandle!=NO_SAMPLE)
{
fMusicFadingIn=TRUE;
return(TRUE);
}
return(FALSE);
}
//********************************************************************************
// MusicPoll
//
// Handles any maintenance the music system needs done. Should be polled from
// the main loop, or somewhere with a high frequency of calls.
//
// Returns: TRUE always
//
//********************************************************************************
BOOLEAN MusicPoll( BOOLEAN fForce )
{
//DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"MusicPoll");
#ifndef WINDOWED_MODE
INT32 iVol;
//DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"MusicPoll: SoundServiceStreams ");
SoundServiceStreams();
//DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"MusicPoll: SoundServiceRandom ");
SoundServiceRandom();
//DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"MusicPoll: Handle Sound every sound overhead time");
// Handle Sound every sound overhead time....
if ( COUNTERDONE( MUSICOVERHEAD ) )
{
//DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"MusicPoll: Reset counter");
// Reset counter
RESETCOUNTER( MUSICOVERHEAD );
if(fMusicFadingIn)
{
//DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"MusicPoll: music fading in");
if(uiMusicHandle!=NO_SAMPLE)
{
iVol=SoundGetVolume(uiMusicHandle);
iVol=__min( (INT32)uiMusicVolume, iVol+gbFadeSpeed );
SoundSetVolume(uiMusicHandle, iVol);
if(iVol==(INT32)uiMusicVolume)
{
fMusicFadingIn=FALSE;
gbFadeSpeed = 1;
}
}
}
else if(fMusicFadingOut)
{
//DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"MusicPoll: music fading out");
if(uiMusicHandle!=NO_SAMPLE)
{
iVol=SoundGetVolume(uiMusicHandle);
iVol=(iVol >=1)? iVol-gbFadeSpeed : 0;
iVol=__max( (INT32)iVol, 0 );
SoundSetVolume(uiMusicHandle, iVol);
if(iVol==0)
{
MusicStop();
fMusicFadingOut=FALSE;
gbFadeSpeed = 1;
}
}
}
//#endif
if ( gfMusicEnded )
{
//DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"MusicPoll: music ended");
// OK, based on our music mode, play another!
//DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String( "Music End Loop %d %d", uiMusicHandle, gubMusicMode ) );
// If we were in victory mode, change!
if ( gbVictorySongCount == 1 || gbDeathSongCount == 1 )
{
if ( gbDeathSongCount == 1 && guiCurrentScreen == GAME_SCREEN )
{
CheckAndHandleUnloadingOfCurrentWorld();
}
if ( gbVictorySongCount == 1 )
{
SetMusicMode( MUSIC_TACTICAL_NOTHING );
}
}
else
{
if ( !gfDontRestartSong )
{
//DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"MusicPoll: don't restart song, StartMusicBasedOnMode");
StartMusicBasedOnMode( );
}
}
gfMusicEnded = FALSE;
gfDontRestartSong = FALSE;
}
}
#endif
//DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"MusicPoll done");
return(TRUE);
}
BOOLEAN SetMusicMode( UINT8 ubMusicMode )
{
static INT8 bPreviousMode = 0;
// OK, check if we want to restore
if ( ubMusicMode == MUSIC_RESTORE )
{
if ( bPreviousMode == MUSIC_TACTICAL_VICTORY || bPreviousMode == MUSIC_TACTICAL_DEATH )
{
bPreviousMode = MUSIC_TACTICAL_NOTHING;
}
ubMusicMode = bPreviousMode;
}
else
{
// Save previous mode...
bPreviousMode = gubOldMusicMode;
}
// if different, start a new music song
if ( gubOldMusicMode != ubMusicMode )
{
// Set mode....
gubMusicMode = ubMusicMode;
//DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String( "Music New Mode %d %d", uiMusicHandle, gubMusicMode ) );
gbVictorySongCount = 0;
gbDeathSongCount = 0;
if(uiMusicHandle!=NO_SAMPLE )
{
// Fade out old music
MusicFadeOut( );
}
else
{
// Change music!
StartMusicBasedOnMode( );
}
}
gubOldMusicMode = gubMusicMode;
return( TRUE );
}
BOOLEAN StartMusicBasedOnMode( )
{
static BOOLEAN fFirstTime = TRUE;
if ( fFirstTime )
{
fFirstTime = FALSE;
bNothingModeSong = NOTHING_A_MUSIC + (INT8)Random( 4 );
bEnemyModeSong = TENSOR_A_MUSIC + (INT8)Random( 3 );
bBattleModeSong = BATTLE_A_MUSIC + (INT8)Random( 2 );
}
//DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String( "StartMusicBasedOnMode() %d %d", uiMusicHandle, gubMusicMode ) );
// Setup a song based on mode we're in!
switch( gubMusicMode )
{
case MUSIC_MAIN_MENU:
// ATE: Don't fade in
gbFadeSpeed = (INT8)uiMusicVolume;
MusicPlay( MENUMIX_MUSIC );
break;
case MUSIC_LAPTOP:
gbFadeSpeed = (INT8)uiMusicVolume;
MusicPlay( MARIMBAD2_MUSIC );
break;
case MUSIC_TACTICAL_NOTHING:
// ATE: Don't fade in
gbFadeSpeed = (INT8)uiMusicVolume;
if( gfUseCreatureMusic )
{
MusicPlay( CREEPY_MUSIC );
}
else
{
MusicPlay( bNothingModeSong );
bNothingModeSong = NOTHING_A_MUSIC + (INT8)Random( 4 );
}
break;
case MUSIC_TACTICAL_ENEMYPRESENT:
// ATE: Don't fade in EnemyPresent...
gbFadeSpeed = (INT8)uiMusicVolume;
if( gfUseCreatureMusic )
{
MusicPlay( CREEPY_MUSIC );
}
else
{
MusicPlay( bEnemyModeSong );
bEnemyModeSong = TENSOR_A_MUSIC + (INT8)Random( 3 );
}
break;
case MUSIC_TACTICAL_BATTLE:
// ATE: Don't fade in
gbFadeSpeed = (INT8)uiMusicVolume;
if( gfUseCreatureMusic )
{
MusicPlay( CREATURE_BATTLE_MUSIC );
}
else
{
MusicPlay( bBattleModeSong );
}
bBattleModeSong = BATTLE_A_MUSIC + (INT8)Random( 2 );
break;
case MUSIC_TACTICAL_VICTORY:
// ATE: Don't fade in EnemyPresent...
gbFadeSpeed = (INT8)uiMusicVolume;
MusicPlay( TRIUMPH_MUSIC );
gbVictorySongCount++;
if( gfUseCreatureMusic && !gbWorldSectorZ )
{ //We just killed all the creatures that just attacked the town.
gfUseCreatureMusic = FALSE;
}
break;
case MUSIC_TACTICAL_DEATH:
// ATE: Don't fade in EnemyPresent...
gbFadeSpeed = (INT8)uiMusicVolume;
MusicPlay( DEATH_MUSIC );
gbDeathSongCount++;
break;
default:
MusicFadeOut( );
break;
}
return( TRUE );
}
void MusicStopCallback( void *pData )
{
//DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String( "Music EndCallback %d %d", uiMusicHandle, gubMusicMode ) );
gfMusicEnded = TRUE;
uiMusicHandle = NO_SAMPLE;
//DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "Music EndCallback completed" );
}
void SetMusicFadeSpeed( INT8 bFadeSpeed )
{
gbFadeSpeed = bFadeSpeed;
}
void FadeMusicForXSeconds( UINT32 uiDelay )
{
INT16 sNumTimeSteps, sNumVolumeSteps;
// get # time steps in delay....
sNumTimeSteps = (INT16)( uiDelay / 10 );
// Devide this by music volume...
sNumVolumeSteps = (INT16)( uiMusicVolume / sNumTimeSteps );
// Set fade delay...
SetMusicFadeSpeed( (INT8)sNumVolumeSteps );
}
void DoneFadeOutDueToEndMusic( void )
{
// Quit game....
InternalLeaveTacticalScreen( MAINMENU_SCREEN );
//SetPendingNewScreen( MAINMENU_SCREEN );
}
+55
View File
@@ -0,0 +1,55 @@
#ifndef _MUSIC_CONTROL_H_
#define _MUSIC_CONTROL_H_
enum MusicList {
MARIMBAD2_MUSIC,
MENUMIX_MUSIC,
NOTHING_A_MUSIC,
NOTHING_B_MUSIC,
NOTHING_C_MUSIC,
NOTHING_D_MUSIC,
TENSOR_A_MUSIC,
TENSOR_B_MUSIC,
TENSOR_C_MUSIC,
TRIUMPH_MUSIC,
DEATH_MUSIC,
BATTLE_A_MUSIC,
BATTLE_B_MUSIC, //same as tensor B
CREEPY_MUSIC,
CREATURE_BATTLE_MUSIC,
NUM_MUSIC
};
enum MusicMode {
MUSIC_NONE,
MUSIC_RESTORE,
MUSIC_MAIN_MENU,
MUSIC_TACTICAL_NOTHING,
MUSIC_TACTICAL_ENEMYPRESENT,
MUSIC_TACTICAL_BATTLE,
MUSIC_TACTICAL_VICTORY,
MUSIC_TACTICAL_DEATH,
MUSIC_LAPTOP,
};
extern UINT32 uiMusicHandle;
extern BOOLEAN fMusicPlaying;
extern UINT8 gubMusicMode;
extern BOOLEAN gfForceMusicToTense;
BOOLEAN SetMusicMode( UINT8 ubMusicMode );
BOOLEAN MusicPlay(UINT32 uiNum);
BOOLEAN MusicSetVolume(UINT32 uiVolume);
UINT32 MusicGetVolume(void);
BOOLEAN MusicStop(void);
BOOLEAN MusicFadeOut(void);
BOOLEAN MusicFadeIn(void);
BOOLEAN MusicPoll( BOOLEAN fForce );
void SetMusicFadeSpeed( INT8 bFadeSpeed );
void FadeMusicForXSeconds( UINT32 uiDelay );
#endif
+1643
View File
File diff suppressed because it is too large Load Diff
+170
View File
@@ -0,0 +1,170 @@
#ifndef __POPUP_BOX
#define __POPUP_BOX
#include "sgp.h"
//#include "local.h"
#include "vobject_blitters.h"
#include "WCheck.h"
#include "Render Dirty.h"
#define MAX_POPUP_BOX_COUNT 20
#define MAX_POPUP_BOX_STRING_COUNT 50 // worst case = 45: move menu with 20 soldiers, each on different squad + overhead
// PopUpBox Flags
#define POPUP_BOX_FLAG_CLIP_TEXT 1
#define POPUP_BOX_FLAG_CENTER_TEXT 2
#define POPUP_BOX_FLAG_RESIZE 4
#define POPUP_BOX_FLAG_CAN_HIGHLIGHT_SHADED_LINES 8
struct popupstring{
STR16 pString;
UINT8 ubForegroundColor;
UINT8 ubBackgroundColor;
UINT8 ubHighLight;
UINT8 ubShade;
UINT8 ubSecondaryShade;
UINT32 uiFont;
BOOLEAN fColorFlag;
BOOLEAN fHighLightFlag;
BOOLEAN fShadeFlag;
BOOLEAN fSecondaryShadeFlag;
};
typedef struct popupstring POPUPSTRING;
typedef POPUPSTRING* POPUPSTRINGPTR;
struct popupbox{
SGPRect Dimensions;
SGPPoint Position;
UINT32 uiLeftMargin;
UINT32 uiRightMargin;
UINT32 uiBottomMargin;
UINT32 uiTopMargin;
UINT32 uiLineSpace;
INT32 iBorderObjectIndex;
INT32 iBackGroundSurface;
UINT32 uiFlags;
UINT32 uiBuffer;
UINT32 uiSecondColumnMinimunOffset;
UINT32 uiSecondColumnCurrentOffset;
UINT32 uiBoxMinWidth;
BOOLEAN fUpdated;
BOOLEAN fShowBox;
POPUPSTRINGPTR Text[ MAX_POPUP_BOX_STRING_COUNT ];
POPUPSTRINGPTR pSecondColumnString[ MAX_POPUP_BOX_STRING_COUNT ];
};
typedef struct popupbox PopUpBo;
typedef PopUpBo *PopUpBoxPt;
static PopUpBoxPt PopUpBoxList[MAX_POPUP_BOX_COUNT];
static UINT32 guiCurrentBox;
// functions
void InitPopUpBoxList();
BOOLEAN CreatePopUpBox(INT32 *hBoxHandle, SGPRect Dimensions, SGPPoint Position, UINT32
uiFlags);
void SetMargins(INT32 hBoxHandle, UINT32 uiLeft, UINT32 uiTop, UINT32 uiBottom,
UINT32 uiRight);
UINT32 GetTopMarginSize( INT32 hBoxHandle );
void SetLineSpace(INT32 hBoxHandle, UINT32 uiLineSpace);
UINT32 GetLineSpace( INT32 hBoxHandle );
void SetBoxBuffer(INT32 hBoxHandle, UINT32 uiBuffer);
void SetBoxPosition(INT32 hBoxHandle,SGPPoint Position);
void GetBoxPosition( INT32 hBoxHandle, SGPPoint *Position );
UINT32 GetNumberOfLinesOfTextInBox( INT32 hBoxHandle );
void SetBoxSize( INT32 hBoxHandle, SGPRect Dimensions );
void GetBoxSize( INT32 hBoxHandle, SGPRect *Dimensions );
void SetBoxFlags( INT32 hBoxHandle, UINT32 uiFlags);
void SetBorderType(INT32 hBoxHandle,INT32 BorderObjectIndex);
void SetBackGroundSurface(INT32 hBoxHandle, INT32 BackGroundSurfaceIndex);
void AddMonoString(UINT32 *hStringHandle, STR16 pString);
void AddColorString(INT32 *hStringHandle, STR16 pString);
void SetPopUpStringFont(INT32 hStringHandle, UINT32 uiFont);
void SetBoxFont(INT32 hBoxHandle, UINT32 uiFont);
UINT32 GetBoxFont( INT32 hBoxHandle );
void SetStringForeground(INT32 hStringHandle, UINT8 ubColor);
void SetStringBackground(INT32 hStringHandle, UINT8 ubColor);
void SetStringHighLight(INT32 hStringHandle, UINT8 ubColor);
void SetStringShade(INT32 hStringHandle, UINT8 ubShade);
void SetBoxForeground(INT32 hBoxHandle, UINT8 ubColor);
void SetBoxBackground(INT32 hBoxHandle, UINT8 ubColor);
void SetBoxHighLight(INT32 hBoxHandle, UINT8 ubColor);
void SetBoxShade(INT32 hBoxHandle, UINT8 ubColor);
void ShadeStringInBox( INT32 hBoxHandle, INT32 iLineNumber );
void UnShadeStringInBox( INT32 hBoxHandle, INT32 iLineNumber );
void HighLightLine(INT32 hStringHandle);
void HighLightBoxLine( INT32 hBoxHandle, INT32 iLineNumber );
void UnHighLightLine(INT32 hStringHandle);
void UnHighLightBox(INT32 hBoxHandle);
void RemoveOneCurrentBoxString(INT32 hStringHandle, BOOLEAN fFillGaps);
void RemoveAllCurrentBoxStrings( void );
void RemoveBox(INT32 hBoxHandle);
void ShowBox(INT32 hBoxHandle);
void HideBox(INT32 hBoxHandle);
void DisplayBoxes(UINT32 uiBuffer);
void DisplayOnePopupBox( UINT32 uiIndex, UINT32 uiBuffer );
void SetCurrentBox(INT32 hBoxHandle);
void GetCurrentBox(INT32 *hBoxHandle);
// resize this box to the text it contains
void ResizeBoxToText(INT32 hBoxHandle);
// force update/redraw of this boxes background
void ForceUpDateOfBox( UINT32 uiIndex );
// force redraw of ALL boxes
void MarkAllBoxesAsAltered( void );
// is the box being displayed?
BOOLEAN IsBoxShown( UINT32 uiHandle );
// is this line int he current boxed in a shaded state?
BOOLEAN GetShadeFlag( INT32 hStringHandle );
// is this line in the current box set to a shaded state ?
BOOLEAN GetBoxShadeFlag( INT32 hBoxHandle, INT32 iLineNumber );
// set boxes foreground color
void SetBoxLineForeground( INT32 iBox, INT32 iStringValue, UINT8 ubColor );
// hide all visible boxes
void HideAllBoxes( void );
// add the second column monocrome string
void AddSecondColumnMonoString( UINT32 *hStringHandle, STR16 pString );
// set the 2nd column font for this box
void SetBoxSecondColumnFont(INT32 hBoxHandle, UINT32 uiFont);
// set the minimum offset
void SetBoxSecondColumnMinimumOffset( INT32 hBoxHandle, UINT32 uiWidth );
void SetBoxSecondColumnCurrentOffset( INT32 hBoxHandle, UINT32 uiCurrentOffset );
void ResizeBoxForSecondStrings( INT32 hBoxHandle );
// fore ground, background, highlight and shade.. for indivdual strings
void SetStringSecondColumnForeground(INT32 hStringHandle, UINT8 ubColor);
void SetStringSecondColumnBackground(INT32 hStringHandle, UINT8 ubColor);
void SetStringSecondColumnHighLight(INT32 hStringHandle, UINT8 ubColor);
void SetStringSecondColumnShade(INT32 hStringHandle, UINT8 ubShade);
// now on a box wide basis, one if recomened to use this function after adding all the strings..rather than on an individual basis
void SetBoxSecondColumnForeground(INT32 hBoxHandle, UINT8 ubColor);
void SetBoxSecondColumnBackground(INT32 hBoxHandle, UINT8 ubColor);
void SetBoxSecondColumnHighLight(INT32 hBoxHandle, UINT8 ubColor);
void SetBoxSecondColumnShade(INT32 hBoxHandle, UINT8 ubColor);
// secondary shades for boxes
void UnSecondaryShadeStringInBox( INT32 hBoxHandle, INT32 iLineNumber );
void SecondaryShadeStringInBox( INT32 hBoxHandle, INT32 iLineNumber );
void SetBoxSecondaryShade( INT32 iBox, UINT8 ubColor );
// min width for box
void SpecifyBoxMinWidth( INT32 hBoxHandle, INT32 iMinWidth );
#endif
+96
View File
@@ -0,0 +1,96 @@
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include "types.h"
#include "himage.h"
#include "Quantize.h"
#include "Quantize Wrap.h"
#include "phys math.h"
typedef struct
{
UINT8 r;
UINT8 g;
UINT8 b;
} RGBValues;
BOOLEAN QuantizeImage( UINT8 *pDest, UINT8 *pSrc, INT16 sWidth, INT16 sHeight, SGPPaletteEntry *pPalette )
{
INT16 sNumColors;
// FIRST CREATE PALETTE
CQuantizer q( 255, 6 );
q.ProcessImage( pSrc, sWidth, sHeight );
sNumColors = q.GetColorCount();
memset( pPalette, 0, sizeof( SGPPaletteEntry ) * 256 );
q.GetColorTable( (RGBQUAD*)pPalette );
// THEN MAP IMAGE TO PALETTE
// OK, MAPIT!
MapPalette( pDest, pSrc, sWidth, sHeight, sNumColors, pPalette );
return( TRUE );
}
void MapPalette( UINT8 *pDest, UINT8 *pSrc, INT16 sWidth, INT16 sHeight, INT16 sNumColors, SGPPaletteEntry *pTable )
{
INT32 cX, cY, cnt, bBest;
real dLowestDist;
real dCubeDist;
vector_3 vTableVal, vSrcVal, vDiffVal;
UINT8 *pData;
RGBValues *pRGBData;
pRGBData = (RGBValues*)pSrc;
for ( cX = 0; cX < sWidth; cX++ )
{
for ( cY = 0; cY < sHeight; cY++ )
{
// OK, FOR EACH PALETTE ENTRY, FIND CLOSEST
bBest = 0;
dLowestDist = (float)9999999;
pData = &(pSrc[ ( cY * sWidth ) + cX ]);
for ( cnt = 0; cnt < sNumColors; cnt++ )
{
vSrcVal.x = pRGBData[ ( cY * sWidth ) + cX ].r;
vSrcVal.y = pRGBData[ ( cY * sWidth ) + cX ].g;
vSrcVal.z = pRGBData[ ( cY * sWidth ) + cX ].b;
vTableVal.x = pTable[ cnt ].peRed;
vTableVal.y = pTable[ cnt ].peGreen;
vTableVal.z = pTable[ cnt ].peBlue;
// Get Dist
vDiffVal = VSubtract( &vSrcVal, &vTableVal );
// Get mag dist
dCubeDist = VGetLength( &(vDiffVal) );
if ( dCubeDist < dLowestDist )
{
dLowestDist = dCubeDist;
bBest = cnt;
}
}
// Now we have the lowest value
// Set into dest
pData = &(pDest[ ( cY * sWidth ) + cX ]);
//Set!
*pData = (UINT8)bBest;
}
}
}
+21
View File
@@ -0,0 +1,21 @@
#ifndef __QUANTIZE_WRAP_H
#define __QUANTIZE_WRAP_H
#ifdef __cplusplus
extern "C" {
#endif
BOOLEAN QuantizeImage( UINT8 *pDest, UINT8 *pSrc, INT16 sWidth, INT16 sHeight, SGPPaletteEntry *pPalette );
void MapPalette( UINT8 *pDest, UINT8 *pSrc, INT16 sWidth, INT16 sHeight, INT16 sNumColors, SGPPaletteEntry *pTable );
#ifdef __cplusplus
}
#endif
#endif
+205
View File
@@ -0,0 +1,205 @@
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include "types.h"
#include <windows.h>
#include "Quantize.h"
#include "types.h"
#include "himage.h"
CQuantizer::CQuantizer (UINT nMaxColors, UINT nColorBits)
{
m_pTree = NULL;
m_nLeafCount = 0;
for (int i=0; i<=(int) nColorBits; i++)
m_pReducibleNodes[i] = NULL;
m_nMaxColors = nMaxColors;
m_nColorBits = nColorBits;
}
CQuantizer::~CQuantizer ()
{
if (m_pTree != NULL)
DeleteTree (&m_pTree);
}
BOOL CQuantizer::ProcessImage (BYTE *pData, int iWidth, int iHeight )
{
BYTE* pbBits;
BYTE r, g, b;
int i, j;
pbBits = (BYTE*)pData;
for (i=0; i<iHeight; i++) {
for (j=0; j<iWidth; j++) {
b = *pbBits++;
g = *pbBits++;
r = *pbBits++;
AddColor (&m_pTree, r, g, b, m_nColorBits, 0, &m_nLeafCount,
m_pReducibleNodes);
while (m_nLeafCount > m_nMaxColors)
ReduceTree (m_nColorBits, &m_nLeafCount, m_pReducibleNodes);
}
//Padding
//pbBits ++;
}
return TRUE;
}
int CQuantizer::GetLeftShiftCount (DWORD dwVal)
{
int nCount = 0;
for (int i=0; i<sizeof (DWORD) * 8; i++) {
if (dwVal & 1)
nCount++;
dwVal >>= 1;
}
return (8 - nCount);
}
int CQuantizer::GetRightShiftCount (DWORD dwVal)
{
for (int i=0; i<sizeof (DWORD) * 8; i++) {
if (dwVal & 1)
return i;
dwVal >>= 1;
}
return -1;
}
void CQuantizer::AddColor (NODE** ppNode, BYTE r, BYTE g, BYTE b,
UINT nColorBits, UINT nLevel, UINT* pLeafCount, NODE** pReducibleNodes)
{
static BYTE mask[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
//
// If the node doesn't exist, create it.
//
if (*ppNode == NULL)
*ppNode = CreateNode (nLevel, nColorBits, pLeafCount,
pReducibleNodes);
//
// Update color information if it's a leaf node.
//
if ((*ppNode)->bIsLeaf) {
(*ppNode)->nPixelCount++;
(*ppNode)->nRedSum += r;
(*ppNode)->nGreenSum += g;
(*ppNode)->nBlueSum += b;
}
//
// Recurse a level deeper if the node is not a leaf.
//
else {
int shift = 7 - nLevel;
int nIndex = (((r & mask[nLevel]) >> shift) << 2) |
(((g & mask[nLevel]) >> shift) << 1) |
((b & mask[nLevel]) >> shift);
AddColor (&((*ppNode)->pChild[nIndex]), r, g, b, nColorBits,
nLevel + 1, pLeafCount, pReducibleNodes);
}
}
NODE* CQuantizer::CreateNode (UINT nLevel, UINT nColorBits, UINT* pLeafCount,
NODE** pReducibleNodes)
{
NODE* pNode;
if ((pNode = (NODE*) HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY,
sizeof (NODE))) == NULL)
return NULL;
pNode->bIsLeaf = (nLevel == nColorBits) ? TRUE : FALSE;
if (pNode->bIsLeaf)
(*pLeafCount)++;
else {
pNode->pNext = pReducibleNodes[nLevel];
pReducibleNodes[nLevel] = pNode;
}
return pNode;
}
void CQuantizer::ReduceTree (UINT nColorBits, UINT* pLeafCount,
NODE** pReducibleNodes)
{
//
// Find the deepest level containing at least one reducible node.
//
for (int i=nColorBits - 1; (i>0) && (pReducibleNodes[i] == NULL); i--);
//
// Reduce the node most recently added to the list at level i.
//
NODE* pNode = pReducibleNodes[i];
pReducibleNodes[i] = pNode->pNext;
UINT nRedSum = 0;
UINT nGreenSum = 0;
UINT nBlueSum = 0;
UINT nChildren = 0;
for (i=0; i<8; i++) {
if (pNode->pChild[i] != NULL) {
nRedSum += pNode->pChild[i]->nRedSum;
nGreenSum += pNode->pChild[i]->nGreenSum;
nBlueSum += pNode->pChild[i]->nBlueSum;
pNode->nPixelCount += pNode->pChild[i]->nPixelCount;
HeapFree (GetProcessHeap (), 0, pNode->pChild[i]);
pNode->pChild[i] = NULL;
nChildren++;
}
}
pNode->bIsLeaf = TRUE;
pNode->nRedSum = nRedSum;
pNode->nGreenSum = nGreenSum;
pNode->nBlueSum = nBlueSum;
*pLeafCount -= (nChildren - 1);
}
void CQuantizer::DeleteTree (NODE** ppNode)
{
for (int i=0; i<8; i++) {
if ((*ppNode)->pChild[i] != NULL)
DeleteTree (&((*ppNode)->pChild[i]));
}
HeapFree (GetProcessHeap (), 0, *ppNode);
*ppNode = NULL;
}
void CQuantizer::GetPaletteColors (NODE* pTree, RGBQUAD* prgb, UINT* pIndex)
{
if (pTree->bIsLeaf) {
prgb[*pIndex].rgbRed =
(BYTE) ((pTree->nRedSum) / (pTree->nPixelCount));
prgb[*pIndex].rgbGreen =
(BYTE) ((pTree->nGreenSum) / (pTree->nPixelCount));
prgb[*pIndex].rgbBlue =
(BYTE) ((pTree->nBlueSum) / (pTree->nPixelCount));
prgb[*pIndex].rgbReserved = 0;
(*pIndex)++;
}
else {
for (int i=0; i<8; i++) {
if (pTree->pChild[i] != NULL)
GetPaletteColors (pTree->pChild[i], prgb, pIndex);
}
}
}
UINT CQuantizer::GetColorCount ()
{
return m_nLeafCount;
}
void CQuantizer::GetColorTable (RGBQUAD* prgb)
{
UINT nIndex = 0;
GetPaletteColors (m_pTree, prgb, &nIndex);
}
+43
View File
@@ -0,0 +1,43 @@
#ifndef __QUANTIZE_H_
#define __QUANTIZE_H_
typedef struct _NODE {
BOOL bIsLeaf; // TRUE if node has no children
UINT nPixelCount; // Number of pixels represented by this leaf
UINT nRedSum; // Sum of red components
UINT nGreenSum; // Sum of green components
UINT nBlueSum; // Sum of blue components
struct _NODE* pChild[8]; // Pointers to child nodes
struct _NODE* pNext; // Pointer to next reducible node
} NODE;
class CQuantizer
{
protected:
NODE* m_pTree;
UINT m_nLeafCount;
NODE* m_pReducibleNodes[9];
UINT m_nMaxColors;
UINT m_nColorBits;
public:
CQuantizer (UINT nMaxColors, UINT nColorBits);
virtual ~CQuantizer ();
BOOL ProcessImage (BYTE *pData, int iWidth, int iHeight );
UINT GetColorCount ();
void GetColorTable (RGBQUAD* prgb);
protected:
int GetLeftShiftCount (DWORD dwVal);
int GetRightShiftCount (DWORD dwVal);
void AddColor (NODE** ppNode, BYTE r, BYTE g, BYTE b, UINT nColorBits,
UINT nLevel, UINT* pLeafCount, NODE** pReducibleNodes);
NODE* CreateNode (UINT nLevel, UINT nColorBits, UINT* pLeafCount,
NODE** pReducibleNodes);
void ReduceTree (UINT nColorBits, UINT* pLeafCount,
NODE** pReducibleNodes);
void DeleteTree (NODE** ppNode);
void GetPaletteColors (NODE* pTree, RGBQUAD* prgb, UINT* pIndex);
};
#endif
+57
View File
@@ -0,0 +1,57 @@
#ifndef RADMALI
#define RADMALI
#ifdef __RAD32__
#include "malloc.h"
#define radmalrad malloc
#define radfrrad free
#else
#ifdef __RADWIN__
#ifdef RADStatus
#define radmalrad(num) GlobalAllocPtr(GMEM_MOVEABLE|GMEM_SHARE,num)
#define radfrrad GlobalFreePtr
#else
#define radmalloc(num) GlobalAllocPtr(GMEM_MOVEABLE|GMEM_SHARE,num)
#define radfree GlobalFreePtr
#endif
#else
#include "malloc.h"
#define radmalrad(num) _fmalloc((int)num)
#define radfrrad _ffree
#endif
#endif
/*
#ifndef radmalloc
RADEXPFUNC void PTR4* RADEXPLINK radmalloc(u32 numbytes)
{
u8 PTR4* temp;
u8 i;
if ((numbytes==0) || (numbytes==0xffffffff))
return(0);
temp=(u8 PTR4*)radmalrad(numbytes+16);
if (temp==0)
return(0);
i=(u8)(16-((u32)temp&15));
temp+=i;
temp[-1]=i;
return(temp);
}
RADEXPFUNC void RADEXPLINK radfree(void PTR4* ptr)
{
if (ptr)
radfrrad( ((u8 PTR4*)ptr)-((u8 PTR4*)ptr)[-1] );
}
#endif
*/
#endif
+42
View File
@@ -0,0 +1,42 @@
#ifndef RADMALWI
#define RADMALWI
#ifdef __RADWINEXT__
u32 GetLimit(u16 sel);
#pragma aux GetLimit = "lsl eax,ax" parm [ax];
RADEXPFUNC void PTR4* RADEXPLINK radmalloc(u32 numbytes)
{
u32 temp;
HGLOBAL handle;
if ((numbytes==0) || (numbytes==0xffffffff))
return(0);
handle=GlobalAlloc(GMEM_SHARE|GMEM_MOVEABLE,numbytes+4);
if (handle) {
GlobalFix(handle);
temp=(u32)GlobalLock(handle);
temp=((u32)_16To32(temp));
((u32 PTR4*)temp)[0]=handle;
return(((u32 PTR4*)temp)+1);
}
return(0);
}
RADEXPFUNC void RADEXPLINK radfree(void PTR4* ptr)
{
HGLOBAL h=((u32 PTR4*)ptr)[-1];
GlobalUnfix(h);
GlobalUnlock(h);
GlobalFree(h);
}
#else
#include "radmal.i"
#endif
#endif
+830
View File
@@ -0,0 +1,830 @@
#ifdef PRECOMPILEDHEADERS
#include "Utils All.h"
#else
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "types.h"
#include "compression.h"
#include "debug.h"
#include "fileman.h"
#include "imgfmt.h"
#include "himage.h"
#include "pcx.h"
#include "impTGA.h"
#include "wcheck.h"
#endif
//CONVERT_TO_16_BIT
BOOLEAN ConvertToETRLE( UINT8 ** ppDest, UINT32 * puiDestLen, UINT8 ** ppSubImageBuffer, UINT16 * pusNumberOfSubImages, UINT8 * p8BPPBuffer, UINT16 usWidth, UINT16 usHeight, UINT32 fFlags );
#define CONVERT_ADD_APPDATA 0x0001
#define CONVERT_ADD_JA2DATA 0x0003
#define CONVERT_ZLIB_COMPRESS 0x0010
#define CONVERT_ETRLE_COMPRESS 0x0020
#define CONVERT_ETRLE_COMPRESS_SINGLE 0x0040
#define CONVERT_ETRLE_NO_SUBIMAGE_SHRINKING 0x0080
#define CONVERT_ETRLE_DONT_SKIP_BLANKS 0x0100
#define CONVERT_ETRLE_FLIC 0x0200
#define CONVERT_ETRLE_FLIC_TRIM 0x0400
#define CONVERT_ETRLE_FLIC_NAME 0x0800
#define CONVERT_TO_8_BIT 0x1000
#define CONVERT_TO_16_BIT 0x2000
// NB 18-bit is actually 24 bit but with only 6 bits used in each byte. I implemented
// it to see how well such images would compress with ZLIB.
#define CONVERT_TO_18_BIT 0x4000
// Defines for inserting red/green/blue values into a 16-bit pixel.
// MASK is the mask to use to get the proper bits out of a byte (part of a 24-bit pixel)
// use SHIFT_RIGHT to move the masked bits to the lowest bits of the byte
// use SHIFT_LEFT to put the bits in their proper place in the 16-bit pixel
#define RED_DEPTH_16 5
#define GREEN_DEPTH_16 6
#define BLUE_DEPTH_16 5
#define RED_MASK_16 0xF8
#define RED_SHIFT_RIGHT_16 3
#define RED_SHIFT_LEFT_16 11
#define GREEN_MASK_16 0xFC
#define GREEN_SHIFT_RIGHT_16 2
#define GREEN_SHIFT_LEFT_16 5
#define BLUE_MASK_16 0xF8
#define BLUE_SHIFT_RIGHT_16 3
#define BLUE_SHIFT_LEFT_16 0
#define RED_DEPTH_24 8
#define GREEN_DEPTH_24 8
#define BLUE_DEPTH_24 8
#define RED_MASK_24 0x00FF0000
#define GREEN_MASK_24 0x0000FF00
#define BLUE_MASK_24 0x000000FF
//#define JA2_OBJECT_DATA_SIZE 16
// this funky union is used for fast 16-bit pixel format conversions
typedef union
{
struct
{
UINT16 usLower;
UINT16 usHigher;
};
UINT32 uiValue;
} SplitUINT32;
void ConvertRGBDistribution555To565( UINT16 * p16BPPData, UINT32 uiNumberOfPixels )
{
UINT16 * pPixel;
UINT32 uiLoop;
SplitUINT32 Pixel;
pPixel = p16BPPData;
for (uiLoop = 0; uiLoop < uiNumberOfPixels; uiLoop++)
{
// we put the 16 pixel bits in the UPPER word of uiPixel, so that we can
// right shift the blue value (at the bottom) into the LOWER word to keep it
// out of the way
Pixel.usHigher = *pPixel;
Pixel.uiValue >>= 5;
// add a least significant bit to green
Pixel.usHigher <<= 1;
// now shift back into the upper word
Pixel.uiValue <<= 5;
// and copy back
*pPixel = Pixel.usHigher;
pPixel++;
}
}
void WriteSTIFile( INT8 *pData, SGPPaletteEntry *pPalette, INT16 sWidth, INT16 sHeight, STR cOutputName, UINT32 fFlags, UINT32 uiAppDataSize )
{
FILE * pOutput;
UINT32 uiOriginalSize;
UINT8 * pOutputBuffer = NULL;
UINT32 uiCompressedSize;
STCIHeader Header;
UINT32 uiLoop;
image_type Image;
SGPPaletteEntry * pSGPPaletteEntry;
STCIPaletteElement STCIPaletteEntry;
STCISubImage * pSubImageBuffer;
UINT16 usNumberOfSubImages;
UINT32 uiSubImageBufferSize=0;
//UINT16 usLoop;
memset( &Header, 0, STCI_HEADER_SIZE );
memset( &Image, 0, sizeof( image_type ));
uiOriginalSize = sWidth * sHeight * (8 / 8);
// set up STCI header for output
memcpy( Header.cID, STCI_ID_STRING, STCI_ID_LEN );
Header.uiTransparentValue = 0;
Header.usHeight = sHeight;
Header.usWidth = sWidth;
Header.ubDepth = 8;
Header.uiOriginalSize = uiOriginalSize;
Header.uiStoredSize = uiOriginalSize;
Header.uiAppDataSize = uiAppDataSize;
Header.fFlags |= STCI_INDEXED;
if (Header.ubDepth == 8)
{
// assume 8-bit pixels indexing into 256 colour palette with 24 bit values in
// the palette
Header.Indexed.uiNumberOfColours = 256;
Header.Indexed.ubRedDepth = 8;
Header.Indexed.ubGreenDepth = 8;
Header.Indexed.ubBlueDepth = 8;
}
if ((Header.fFlags & STCI_INDEXED) && (fFlags & CONVERT_ETRLE_COMPRESS))
{
if( !ConvertToETRLE( &pOutputBuffer, &uiCompressedSize, (UINT8 **) &pSubImageBuffer, &usNumberOfSubImages, (UINT8 *)pData, sWidth, sHeight, fFlags ) )
{
}
uiSubImageBufferSize = (UINT32) usNumberOfSubImages * STCI_SUBIMAGE_SIZE;
Header.Indexed.usNumberOfSubImages = usNumberOfSubImages;
Header.uiStoredSize = uiCompressedSize;
Header.fFlags |= STCI_ETRLE_COMPRESSED;
}
//
// save file
//
pOutput = fopen( cOutputName, "wb" );
if (pOutput == NULL )
{
return;
}
// write header
fwrite( &Header, STCI_HEADER_SIZE, 1, pOutput );
// write palette and subimage structs, if any
if (Header.fFlags & STCI_INDEXED)
{
if (pPalette != NULL)
{
// have to convert palette to STCI format!
pSGPPaletteEntry = pPalette;
for (uiLoop = 0; uiLoop < 256; uiLoop++)
{
STCIPaletteEntry.ubRed = pSGPPaletteEntry[uiLoop].peRed;
STCIPaletteEntry.ubGreen = pSGPPaletteEntry[uiLoop].peGreen;
STCIPaletteEntry.ubBlue = pSGPPaletteEntry[uiLoop].peBlue;
fwrite( &STCIPaletteEntry, STCI_PALETTE_ELEMENT_SIZE, 1, pOutput );
}
}
if (Header.fFlags & STCI_ETRLE_COMPRESSED)
{
fwrite( pSubImageBuffer, uiSubImageBufferSize, 1, pOutput );
}
}
// write file data
if (Header.fFlags & STCI_ZLIB_COMPRESSED || Header.fFlags & STCI_ETRLE_COMPRESSED)
{
fwrite( pOutputBuffer, Header.uiStoredSize, 1, pOutput );
}
else
{
fwrite( Image.pImageData, Header.uiStoredSize, 1, pOutput );
}
// write app-specific data (blanked to 0)
if (Image.pAppData == NULL )
{
if (Header.uiAppDataSize > 0)
{
for (uiLoop = 0; uiLoop < Header.uiAppDataSize; uiLoop++)
{
fputc( 0, pOutput );
}
}
}
else
{
fwrite( Image.pAppData, Header.uiAppDataSize, 1, pOutput );
}
fclose( pOutput );
if( pOutputBuffer != NULL )
{
MemFree( pOutputBuffer );
}
}
#define COMPRESS_TRANSPARENT 0x80
#define COMPRESS_NON_TRANSPARENT 0x00
#define COMPRESS_RUN_LIMIT 0x7F
#define TCI 0x00
#define WI 0xFF
UINT32 ETRLECompressSubImage( UINT8 * pDest, UINT32 uiDestLen, UINT8 * p8BPPBuffer, UINT16 usWidth, UINT16 usHeight, STCISubImage * pSubImage );
UINT32 ETRLECompress( UINT8 * pDest, UINT32 uiDestLen, UINT8 * pSource, UINT32 uiSourceLen );
BOOLEAN DetermineOffset( UINT32 * puiOffset, UINT16 usWidth, UINT16 usHeight, INT16 sX, INT16 sY );
BOOLEAN GoPastWall( INT16 * psNewX, INT16 * psNewY, UINT16 usWidth, UINT16 usHeight, UINT8 * pCurrent, INT16 sCurrX, INT16 sCurrY );
BOOLEAN GoToNextSubImage( INT16 * psNewX, INT16 * psNewY, UINT8 * p8BPPBuffer, UINT16 usWidth, UINT16 usHeight, INT16 sOrigX, INT16 sOrigY );
BOOLEAN DetermineSubImageSize( UINT8 * p8BPPBuffer, UINT16 usWidth, UINT16 usHeight, STCISubImage * pSubImage );
BOOLEAN DetermineSubImageUsedSize( UINT8 * p8BPPBuffer, UINT16 usWidth, UINT16 usHeight, STCISubImage * pSubImage );
BOOLEAN CheckForDataInRows( INT16 * psXValue, INT16 sXIncrement, UINT8 * p8BPPBuffer, UINT16 usWidth, UINT16 usHeight, STCISubImage * pSubImage );
BOOLEAN CheckForDataInCols( INT16 * psXValue, INT16 sXIncrement, UINT8 * p8BPPBuffer, UINT16 usWidth, UINT16 usHeight, STCISubImage * pSubImage );
UINT8 * CheckForDataInRowOrColumn( UINT8 * pPixel, UINT16 usIncrement, UINT16 usNumberOfPixels );
BOOLEAN ConvertToETRLE( UINT8 ** ppDest, UINT32 * puiDestLen, UINT8 ** ppSubImageBuffer, UINT16 * pusNumberOfSubImages, UINT8 * p8BPPBuffer, UINT16 usWidth, UINT16 usHeight, UINT32 fFlags )
{
INT16 sCurrX;
INT16 sCurrY;
INT16 sNextX;
INT16 sNextY;
UINT8 * pOutputNext;
UINT8 * pTemp;
BOOLEAN fContinue = TRUE;
BOOLEAN fOk = TRUE;
BOOLEAN fStore;
BOOLEAN fNextExists;
STCISubImage * pCurrSubImage;
STCISubImage TempSubImage;
UINT32 uiCompressedSize = 0;
UINT32 uiSubImageCompressedSize;
UINT32 uiSpaceLeft;
// worst-case situation estimate
uiSpaceLeft = (UINT32) usWidth * (UINT32) usHeight * 3;
*ppDest = (UINT8 *) MemAlloc( uiSpaceLeft );
CHECKF( *ppDest );
*puiDestLen = uiSpaceLeft;
pOutputNext = *ppDest;
if (fFlags & CONVERT_ETRLE_COMPRESS_SINGLE)
{
// there are no walls in this image, but we treat it as a "subimage" for
// the purposes of calling the compressor
// we want a 1-element SubImage array for this...
// allocate!
*pusNumberOfSubImages = 1;
*ppSubImageBuffer = (UINT8 *) MemAlloc( STCI_SUBIMAGE_SIZE );
if (!(*ppSubImageBuffer))
{
MemFree( *ppDest );
return( FALSE );
}
pCurrSubImage = (STCISubImage *) *ppSubImageBuffer;
pCurrSubImage->sOffsetX = 0;
pCurrSubImage->sOffsetY = 0;
pCurrSubImage->usWidth = usWidth;
pCurrSubImage->usHeight = usHeight;
if (!(fFlags & CONVERT_ETRLE_NO_SUBIMAGE_SHRINKING))
{
if (!(DetermineSubImageUsedSize( p8BPPBuffer, usWidth, usHeight, pCurrSubImage )))
{
MemFree( *ppDest );
return( FALSE );
}
}
uiSubImageCompressedSize = ETRLECompressSubImage( pOutputNext, uiSpaceLeft, p8BPPBuffer, usWidth, usHeight, pCurrSubImage );
if (uiSubImageCompressedSize == 0)
{
MemFree( *ppDest );
return( FALSE );
}
else
{
pCurrSubImage->uiDataOffset = 0;
pCurrSubImage->uiDataLength = uiSubImageCompressedSize;
*puiDestLen = uiSubImageCompressedSize;
return( TRUE );
}
}
else
{
// skip any initial wall bytes to find the first subimage
if (!GoPastWall( &sCurrX, &sCurrY, usWidth, usHeight, p8BPPBuffer, 0, 0 ))
{ // no subimages!
MemFree( *ppDest );
return( FALSE );
}
*ppSubImageBuffer = NULL;
*pusNumberOfSubImages = 0;
while (fContinue)
{
// allocate more memory for SubImage structures, and set the current pointer to the last one
pTemp = (UINT8 *) MemRealloc( *ppSubImageBuffer, (*pusNumberOfSubImages + 1) * STCI_SUBIMAGE_SIZE );
if (pTemp == NULL)
{
fOk = FALSE;
break;
}
else
{
*ppSubImageBuffer = pTemp;
}
pCurrSubImage = (STCISubImage *) (*ppSubImageBuffer + (*pusNumberOfSubImages) * STCI_SUBIMAGE_SIZE);
pCurrSubImage->sOffsetX = sCurrX;
pCurrSubImage->sOffsetY = sCurrY;
// determine the subimage's full size
if (!DetermineSubImageSize( p8BPPBuffer, usWidth, usHeight, pCurrSubImage ))
{
fOk = FALSE;
break;
}
if (*pusNumberOfSubImages == 0 && pCurrSubImage->usWidth == usWidth && pCurrSubImage->usHeight == usHeight)
{
printf( "\tWarning: no walls (subimage delimiters) found.\n" );
}
memcpy( &TempSubImage, pCurrSubImage, STCI_SUBIMAGE_SIZE );
if (DetermineSubImageUsedSize( p8BPPBuffer, usWidth, usHeight, &TempSubImage))
{
// image has nontransparent data; we definitely want to store it
fStore = TRUE;
if (!(fFlags & CONVERT_ETRLE_NO_SUBIMAGE_SHRINKING))
{
memcpy( pCurrSubImage, &TempSubImage, STCI_SUBIMAGE_SIZE );
}
}
else if (fFlags & CONVERT_ETRLE_DONT_SKIP_BLANKS)
{
// image is transparent; we will store it if there is another subimage
// to the right of it on the same line
// find the next subimage
fNextExists = GoToNextSubImage( &sNextX, &sNextY, p8BPPBuffer, usWidth, usHeight, sCurrX, sCurrY );
if (fNextExists && sNextY == sCurrY )
{
fStore = TRUE;
}
else
{
// junk transparent section at the end of the line!
fStore = FALSE;
}
}
else
{
// transparent data; discarding
fStore = FALSE;
}
if (fStore)
{
// we want to store this subimage!
uiSubImageCompressedSize = ETRLECompressSubImage( pOutputNext, uiSpaceLeft, p8BPPBuffer, usWidth, usHeight, pCurrSubImage );
if (uiSubImageCompressedSize == 0)
{
fOk = FALSE;
break;
}
pCurrSubImage->uiDataOffset = (*puiDestLen - uiSpaceLeft);
pCurrSubImage->uiDataLength = uiSubImageCompressedSize;
// this is a cheap hack; the sOffsetX and sOffsetY values have been used
// to store the location of the subimage within the whole image. Now
// we want the offset within the subimage, so, we subtract the coordatines
// for the upper-left corner of the subimage.
pCurrSubImage->sOffsetX -= sCurrX;
pCurrSubImage->sOffsetY -= sCurrY;
(*pusNumberOfSubImages)++;
pOutputNext += uiSubImageCompressedSize;
uiSpaceLeft -= uiSubImageCompressedSize;
}
// find the next subimage
fContinue = GoToNextSubImage( &sCurrX, &sCurrY, p8BPPBuffer, usWidth, usHeight, sCurrX, sCurrY );
}
}
if (fOk)
{
*puiDestLen -= uiSpaceLeft;
return( TRUE );
}
else
{
MemFree( *ppDest );
if (*ppSubImageBuffer != NULL)
{
MemFree( *ppSubImageBuffer );
}
return( FALSE );
}
}
UINT32 ETRLECompressSubImage( UINT8 * pDest, UINT32 uiDestLen, UINT8 * p8BPPBuffer, UINT16 usWidth, UINT16 usHeight, STCISubImage * pSubImage )
{
UINT16 usLoop;
UINT32 uiScanLineCompressedSize;
UINT32 uiSpaceLeft = uiDestLen;
UINT32 uiOffset;
UINT8 * pCurrent;
CHECKF( DetermineOffset( &uiOffset, usWidth, usHeight, pSubImage->sOffsetX, pSubImage->sOffsetY ) )
pCurrent = p8BPPBuffer + uiOffset;
for (usLoop = 0; usLoop < pSubImage->usHeight; usLoop++)
{
uiScanLineCompressedSize = ETRLECompress( pDest, uiSpaceLeft, pCurrent, pSubImage->usWidth );
if (uiScanLineCompressedSize == 0 )
{ // there wasn't enough room to complete the compression!
return( 0 );
}
// reduce the amount of available space
uiSpaceLeft -= uiScanLineCompressedSize;
pDest += uiScanLineCompressedSize;
// go to the next scanline
pCurrent += usWidth;
}
return( uiDestLen - uiSpaceLeft );
}
UINT32 ETRLECompress( UINT8 * pDest, UINT32 uiDestLen, UINT8 * pSource, UINT32 uiSourceLen )
{ // Compress a buffer (a scanline) into ETRLE format, which is a series of runs.
// Each run starts with a byte whose high bit is 1 if the run is compressed, 0 otherwise.
// The lower seven bits of that byte indicate the length of the run
// ETRLECompress returns the number of bytes used by the compressed buffer, or 0 if an error
// occurred
// uiSourceLoc keeps track of our current position in the
// source
UINT32 uiSourceLoc = 0;
// uiCurrentSourceLoc is used to look ahead in the source to
// determine the length of runs
UINT32 uiCurrentSourceLoc = 0;
UINT32 uiDestLoc = 0;
UINT8 ubLength = 0;
while (uiSourceLoc < uiSourceLen && uiDestLoc < uiDestLen)
{
if (pSource[uiSourceLoc] == TCI)
{ // transparent run - determine its length
do
{
uiCurrentSourceLoc++;
ubLength++;
}
while ((uiCurrentSourceLoc < uiSourceLen) && pSource[uiCurrentSourceLoc] == TCI && (ubLength < COMPRESS_RUN_LIMIT));
// output run-byte
pDest[uiDestLoc] = ubLength | COMPRESS_TRANSPARENT;
// update location
uiSourceLoc += ubLength;
uiDestLoc += 1;
}
else
{ // non-transparent run - determine its length
do
{
uiCurrentSourceLoc++;
ubLength++;
}
while ((uiCurrentSourceLoc < uiSourceLen) && (pSource[uiCurrentSourceLoc] != TCI) && (ubLength < COMPRESS_RUN_LIMIT));
if (uiDestLoc + ubLength < uiDestLen)
{
// output run-byte
pDest[uiDestLoc++] = ubLength | COMPRESS_NON_TRANSPARENT;
// output run (and update location)
memcpy( pDest + uiDestLoc, pSource + uiSourceLoc, ubLength );
uiSourceLoc += ubLength;
uiDestLoc += ubLength;
}
else
{ // not enough room in dest buffer to copy the run!
return( 0 );
}
}
uiCurrentSourceLoc = uiSourceLoc;
ubLength = 0;
}
if (uiDestLoc >= uiDestLen)
{
return( 0 );
}
else
{
// end with a run of 0 length (which might as well be non-transparent,
// giving a 0-byte
pDest[uiDestLoc++] = 0;
return( uiDestLoc );
}
}
BOOLEAN DetermineOffset( UINT32 * puiOffset, UINT16 usWidth, UINT16 usHeight, INT16 sX, INT16 sY )
{
if (sX < 0 || sY < 0)
{
return( FALSE );
}
*puiOffset = (UINT32) sY * (UINT32) usWidth + (UINT32) sX;
if (*puiOffset >= (UINT32) usWidth * (UINT32) usHeight)
{
return( FALSE );
}
return( TRUE );
}
BOOLEAN GoPastWall( INT16 * psNewX, INT16 * psNewY, UINT16 usWidth, UINT16 usHeight, UINT8 * pCurrent, INT16 sCurrX, INT16 sCurrY )
{
// If the current pixel is a wall, we assume that it is on a horizontal wall and
// search right, wrapping around the end of scanlines, until we find non-wall data.
while (*pCurrent == WI)
{
sCurrX++;
pCurrent++;
if (sCurrX == usWidth)
{ // wrap our logical coordinates!
sCurrX = 0;
sCurrY++;
if( sCurrY == usHeight)
{
// no more images!
return( FALSE );
}
}
}
*psNewX = sCurrX;
*psNewY = sCurrY;
return( TRUE );
}
BOOLEAN GoToNextSubImage( INT16 * psNewX, INT16 * psNewY, UINT8 * p8BPPBuffer, UINT16 usWidth, UINT16 usHeight, INT16 sOrigX, INT16 sOrigY )
{ // return the coordinates of the next subimage in the image
// (either to the right, or the first of the next row down
INT16 sCurrX = sOrigX;
INT16 sCurrY = sOrigY;
UINT32 uiOffset;
UINT8 * pCurrent;
BOOLEAN fFound = TRUE;
CHECKF( DetermineOffset( &uiOffset, usWidth, usHeight, sCurrX, sCurrY ) )
pCurrent = p8BPPBuffer + uiOffset;
if (*pCurrent == WI)
{
return( GoPastWall( psNewX, psNewY, usWidth, usHeight, pCurrent, sCurrX, sCurrY ) );
}
else
{
// The current pixel is not a wall. We scan right past all non-wall data to skip to
// the right-hand end of the subimage, then right past all wall data to skip a vertical
// wall, and should find ourselves at another subimage.
// If we hit the right edge of the image, we back up to our start point, go DOWN to
// the bottom of the image to the horizontal wall, and then recurse to go along it
// to the right place on the next scanline
while (*pCurrent != WI)
{
sCurrX++;
pCurrent++;
if (sCurrX == usWidth)
{ // there are no more images to the right!
fFound = FALSE;
break;
}
}
if (sCurrX < usWidth)
{
// skip all wall data to the right, starting at the new current position
while (*pCurrent == WI)
{
sCurrX++;
pCurrent++;
if (sCurrX == usWidth)
{ // there are no more images to the right!
fFound = FALSE;
break;
}
}
}
if (fFound)
{
*psNewX = sCurrX;
*psNewY = sCurrY;
return( TRUE );
}
else
{
// go back to the beginning of the subimage and scan down
sCurrX = sOrigX;
pCurrent = p8BPPBuffer + uiOffset;
// skip all non-wall data below, starting at the current position
while (*pCurrent != WI)
{
sCurrY++;
pCurrent += usWidth;
if (sCurrY == usHeight)
{ // there are no more images!
return( FALSE );
}
}
// We are now at the horizontal wall at the bottom of the current image
return( GoPastWall( psNewX, psNewY, usWidth, usHeight, pCurrent, sCurrX, sCurrY ) );
}
}
}
BOOLEAN DetermineSubImageSize( UINT8 * p8BPPBuffer, UINT16 usWidth, UINT16 usHeight, STCISubImage * pSubImage )
{
UINT32 uiOffset;
UINT8 * pCurrent;
INT16 sCurrX = pSubImage->sOffsetX;
INT16 sCurrY = pSubImage->sOffsetY;
if (!DetermineOffset( &uiOffset, usWidth, usHeight, sCurrX, sCurrY ))
{
return( FALSE );
}
// determine width
pCurrent = p8BPPBuffer + uiOffset;
do
{
sCurrX++;
pCurrent++;
} while( *pCurrent != WI && sCurrX < usWidth );
pSubImage->usWidth = sCurrX - pSubImage->sOffsetX;
// determine height
pCurrent = p8BPPBuffer + uiOffset;
do
{
sCurrY++;
pCurrent += usWidth;
} while( *pCurrent != WI && sCurrY < usHeight );
pSubImage->usHeight = sCurrY - pSubImage->sOffsetY;
return( TRUE );
}
BOOLEAN DetermineSubImageUsedSize( UINT8 * p8BPPBuffer, UINT16 usWidth, UINT16 usHeight, STCISubImage * pSubImage )
{
INT16 sNewValue;
// to do our search loops properly, we can't change the height and width of the
// subimages until we're done all of our shrinks
UINT16 usNewHeight;
UINT16 usNewWidth;
UINT16 usNewX;
UINT16 usNewY;
// shrink from the top
if (CheckForDataInRows( &sNewValue, 1, p8BPPBuffer, usWidth, usHeight, pSubImage ))
{
usNewY = sNewValue;
}
else
{
return( FALSE );
}
// shrink from the bottom
if (CheckForDataInRows( &sNewValue, -1, p8BPPBuffer, usWidth, usHeight, pSubImage ))
{
usNewHeight = (UINT16) sNewValue - usNewY + 1;
}
else
{
return( FALSE );
}
// shrink from the left
if (CheckForDataInCols( &sNewValue, 1, p8BPPBuffer, usWidth, usHeight, pSubImage ))
{
usNewX = sNewValue;
}
else
{
return( FALSE );
}
// shrink from the right
if (CheckForDataInCols( &sNewValue, -1, p8BPPBuffer, usWidth, usHeight, pSubImage ))
{
usNewWidth = (UINT16) sNewValue - usNewX + 1;
}
else
{
return( FALSE );
}
pSubImage->sOffsetX = usNewX;
pSubImage->sOffsetY = usNewY;
pSubImage->usHeight = usNewHeight;
pSubImage->usWidth = usNewWidth;
return( TRUE );
}
BOOLEAN CheckForDataInRows( INT16 * psYValue, INT16 sYIncrement, UINT8 * p8BPPBuffer, UINT16 usWidth, UINT16 usHeight, STCISubImage * pSubImage )
{
INT16 sCurrY;
UINT32 uiOffset;
UINT8 * pCurrent;
UINT16 usLoop;
if (sYIncrement == 1)
{
sCurrY = pSubImage->sOffsetY;
}
else if (sYIncrement == -1)
{
sCurrY = pSubImage->sOffsetY + (INT16) pSubImage->usHeight - 1;
}
else
{
// invalid value!
return( FALSE );
}
for (usLoop = 0; usLoop < pSubImage->usHeight; usLoop++)
{
if (!DetermineOffset( &uiOffset, usWidth, usHeight, pSubImage->sOffsetX, (INT16) sCurrY))
{
return( FALSE );
}
pCurrent = p8BPPBuffer + uiOffset;
pCurrent = CheckForDataInRowOrColumn( pCurrent, 1, pSubImage->usWidth );
if (pCurrent)
{
// non-null data found!
*psYValue = sCurrY;
return( TRUE );
}
sCurrY += sYIncrement;
}
return( FALSE );
}
BOOLEAN CheckForDataInCols( INT16 * psXValue, INT16 sXIncrement, UINT8 * p8BPPBuffer, UINT16 usWidth, UINT16 usHeight, STCISubImage * pSubImage )
{
INT16 sCurrX;
UINT32 uiOffset;
UINT8 * pCurrent;
UINT16 usLoop;
if (sXIncrement == 1)
{
sCurrX = pSubImage->sOffsetX;
}
else if (sXIncrement == -1)
{
sCurrX = pSubImage->sOffsetX + (INT16) pSubImage->usWidth - 1;
}
else
{
// invalid value!
return( FALSE );
}
for (usLoop = 0; usLoop < pSubImage->usWidth; usLoop++)
{
if (!DetermineOffset( &uiOffset, usWidth, usHeight, (UINT16) sCurrX, pSubImage->sOffsetY))
{
return( FALSE );
}
pCurrent = p8BPPBuffer + uiOffset;
pCurrent = CheckForDataInRowOrColumn( pCurrent, usWidth, pSubImage->usHeight );
if (pCurrent)
{
// non-null data found!
*psXValue = sCurrX;
return( TRUE );
}
sCurrX += sXIncrement;
}
return( FALSE );
}
UINT8 * CheckForDataInRowOrColumn( UINT8 * pPixel, UINT16 usIncrement, UINT16 usNumberOfPixels )
{
// This function, passed the right increment value, can scan either across or
// down an image to find a non-transparent pixel
UINT16 usLoop;
for (usLoop = 0; usLoop < usNumberOfPixels; usLoop++)
{
if (*pPixel != TCI)
{
return( pPixel );
}
else
{
pPixel += usIncrement;
}
}
return( NULL );
}
+11
View File
@@ -0,0 +1,11 @@
#ifndef __STCICONVERT_H
#define __STCICONVERT_H
#define CONVERT_ETRLE_COMPRESS 0x0020
#define CONVERT_TO_8_BIT 0x1000
void WriteSTIFile( INT8 *pData, SGPPaletteEntry *pPalette, INT16 sWidth, INT16 sHeight, STR cOutputName, UINT32 fFlags, UINT32 uiAppDataSize );
#endif
+778
View File
@@ -0,0 +1,778 @@
#ifdef PRECOMPILEDHEADERS
#include "Utils All.h"
#else
#include "Types.h"
#include "WordWrap.h"
#include "Render Dirty.h"
#include "Utilities.h"
#include "Cursors.h"
#include "WCheck.h"
#include "Slider.h"
#include "SysUtil.h"
#include "Line.h"
#endif
///////////////////////////////////////////////////
//
// Defines
//
///////////////////////////////////////////////////
#define DEFUALT_SLIDER_SIZE 7
#define STEEL_SLIDER_WIDTH 42
#define STEEL_SLIDER_HEIGHT 25
typedef struct TAG_SLIDER
{
UINT32 uiSliderID;
UINT8 ubStyle;
UINT16 usPosX;
UINT16 usPosY;
UINT16 usWidth;
UINT16 usHeight;
UINT16 usNumberOfIncrements;
SLIDER_CHANGE_CALLBACK SliderChangeCallback;
UINT16 usCurrentIncrement;
UINT16 usBackGroundColor;
MOUSE_REGION ScrollAreaMouseRegion;
UINT32 uiSliderBoxImage;
UINT16 usCurrentSliderBoxPosition;
SGPRect LastRect;
UINT32 uiFlags;
UINT8 ubSliderWidth;
UINT8 ubSliderHeight;
struct TAG_SLIDER *pNext;
struct TAG_SLIDER *pPrev;
} SLIDER;
//ddd
///////////////////////////////////////////////////
//
// Global Variables
//
///////////////////////////////////////////////////
SLIDER *pSliderHead = NULL;
UINT32 guiCurrentSliderID=1;
BOOLEAN gfSliderInited=FALSE;
BOOLEAN gfCurrentSliderIsAnchored=FALSE; //if true, the current selected slider mouse button is down
SLIDER *gpCurrentSlider=NULL;
UINT32 guiSliderBoxImage=0;
//ggg
//Mouse regions for the currently selected save game
void SelectedSliderButtonCallBack(MOUSE_REGION * pRegion, INT32 iReason );
void SelectedSliderMovementCallBack(MOUSE_REGION * pRegion, INT32 reason );
///////////////////////////////////////////////////
//
// Function Prototypes
//
///////////////////////////////////////////////////
void OptDisplayLine( UINT16 usStartX, UINT16 usStartY, UINT16 EndX, UINT16 EndY, INT16 iColor );
void RenderSelectedSliderBar( SLIDER *pSlider );
void CalculateNewSliderBoxPosition( SLIDER *pSlider );
SLIDER *GetSliderFromID( UINT32 uiSliderID );
void RenderSliderBox( SLIDER *pSlider );
void CalculateNewSliderIncrement( UINT32 uiSliderID, UINT16 usPosX );
//ppp
///////////////////////////////////////////////////
//
// Functions
//
///////////////////////////////////////////////////
BOOLEAN InitSlider()
{
VOBJECT_DESC VObjectDesc;
// load Slider Box Graphic graphic and add it
VObjectDesc.fCreateFlags=VOBJECT_CREATE_FROMFILE;
FilenameForBPP("INTERFACE\\SliderBox.sti", VObjectDesc.ImageFile);
CHECKF(AddVideoObject(&VObjectDesc, &guiSliderBoxImage ));
gfSliderInited = TRUE;
return( TRUE );
}
void ShutDownSlider()
{
SLIDER *pRemove = NULL;
SLIDER *pTemp = NULL;
AssertMsg( gfSliderInited, "Trying to ShutDown the Slider System when it was never inited");
//Do a cehck to see if there are still active nodes
pTemp = pSliderHead;
while( pTemp )
{
pRemove = pTemp;
pTemp = pTemp->pNext;
RemoveSliderBar( pRemove->uiSliderID );
//Report an error
}
//if so report an errror
gfSliderInited = 0;
DeleteVideoObjectFromIndex( guiSliderBoxImage );
}
INT32 AddSlider( UINT8 ubStyle, UINT16 usCursor, UINT16 usPosX, UINT16 usPosY, UINT16 usWidth, UINT16 usNumberOfIncrements, INT8 sPriority, SLIDER_CHANGE_CALLBACK SliderChangeCallback, UINT32 uiFlags )
{
SLIDER *pTemp = NULL;
SLIDER *pNewSlider = NULL;
INT32 iNewID=0;
UINT32 cnt=0;
UINT16 usIncrementWidth=0;
AssertMsg( gfSliderInited, "Trying to Add a Slider Bar when the Slider System was never inited");
//checks
if( ubStyle >= NUM_SLIDER_STYLES )
return( -1 );
pNewSlider = (SLIDER *) MemAlloc( sizeof( SLIDER ) );
if( pNewSlider == NULL )
{
return( -1 );
}
memset( pNewSlider, 0, sizeof( SLIDER ) );
//Assign the settings to the current slider
pNewSlider->ubStyle = ubStyle;
pNewSlider->usPosX = usPosX;
pNewSlider->usPosY = usPosY;
// pNewSlider->usWidth = usWidth;
pNewSlider->usNumberOfIncrements = usNumberOfIncrements;
pNewSlider->SliderChangeCallback = SliderChangeCallback;
pNewSlider->usCurrentIncrement = 0;
pNewSlider->usBackGroundColor = Get16BPPColor( FROMRGB( 255, 255, 255 ) );
pNewSlider->uiFlags = uiFlags;
//Get a new Identifier for the slider
//Temp just increment for now
pNewSlider->uiSliderID = guiCurrentSliderID;
//increment counter
guiCurrentSliderID++;
//
// Create the mouse regions for each increment in the slider
//
//add the region
usPosX = pNewSlider->usPosX;
usPosY = pNewSlider->usPosY;
//Add the last one, the width will be whatever is left over
switch( ubStyle )
{
case SLIDER_VERTICAL_STEEL:
pNewSlider->uiFlags |= SLIDER_VERTICAL;
pNewSlider->usWidth = STEEL_SLIDER_WIDTH;
pNewSlider->usHeight = usWidth;
pNewSlider->ubSliderWidth = STEEL_SLIDER_WIDTH;
pNewSlider->ubSliderHeight = STEEL_SLIDER_HEIGHT;
MSYS_DefineRegion( &pNewSlider->ScrollAreaMouseRegion, (UINT16)(usPosX-pNewSlider->usWidth/2), usPosY, (UINT16)(usPosX+pNewSlider->usWidth/2), (UINT16)(pNewSlider->usPosY+pNewSlider->usHeight), sPriority,
usCursor, SelectedSliderMovementCallBack, SelectedSliderButtonCallBack );
MSYS_SetRegionUserData( &pNewSlider->ScrollAreaMouseRegion, 1, pNewSlider->uiSliderID );
break;
case SLIDER_DEFAULT_STYLE:
default:
pNewSlider->uiFlags |= SLIDER_HORIZONTAL;
pNewSlider->usWidth = usWidth;
pNewSlider->usHeight = DEFUALT_SLIDER_SIZE;
MSYS_DefineRegion( &pNewSlider->ScrollAreaMouseRegion, usPosX, (UINT16)(usPosY-DEFUALT_SLIDER_SIZE), (UINT16)(pNewSlider->usPosX+pNewSlider->usWidth), (UINT16)(usPosY+DEFUALT_SLIDER_SIZE), sPriority,
usCursor, SelectedSliderMovementCallBack, SelectedSliderButtonCallBack );
MSYS_SetRegionUserData( &pNewSlider->ScrollAreaMouseRegion, 1, pNewSlider->uiSliderID );
break;
}
//
// Load the graphic image for the slider box
//
//add the slider into the list
pTemp = pSliderHead;
//if its the first time in
if( pSliderHead == NULL )
{
pSliderHead = pNewSlider;
pNewSlider->pNext = NULL;
}
else
{
while( pTemp->pNext != NULL )
{
pTemp = pTemp->pNext;
}
pTemp->pNext = pNewSlider;
pNewSlider->pPrev = pTemp;
pNewSlider->pNext = NULL;
}
CalculateNewSliderBoxPosition( pNewSlider );
return( pNewSlider->uiSliderID );
}
void RenderAllSliderBars()
{
SLIDER *pTemp = NULL;
// set the currently selectd slider bar
if( gfLeftButtonState && gpCurrentSlider != NULL )
{
UINT16 usPosY = 0;
if( gusMouseYPos < gpCurrentSlider->usPosY )
usPosY = 0;
else
usPosY = gusMouseYPos - gpCurrentSlider->usPosY;
//if the mouse
CalculateNewSliderIncrement( gpCurrentSlider->uiSliderID, usPosY );
}
else
{
gpCurrentSlider = NULL;
}
pTemp = pSliderHead;
while( pTemp )
{
RenderSelectedSliderBar( pTemp );
pTemp = pTemp->pNext;
}
}
void RenderSelectedSliderBar( SLIDER *pSlider )
{
if( pSlider->uiFlags & SLIDER_VERTICAL )
{
}
else
{
//display the background ( the bar )
OptDisplayLine( (UINT16)(pSlider->usPosX+1), (UINT16)(pSlider->usPosY-1), (UINT16)(pSlider->usPosX + pSlider->usWidth-1), (UINT16)(pSlider->usPosY-1), pSlider->usBackGroundColor );
OptDisplayLine( pSlider->usPosX, pSlider->usPosY, (UINT16)(pSlider->usPosX + pSlider->usWidth), pSlider->usPosY, pSlider->usBackGroundColor );
OptDisplayLine( (UINT16)(pSlider->usPosX+1), (UINT16)(pSlider->usPosY+1), (UINT16)(pSlider->usPosX + pSlider->usWidth-1), (UINT16)(pSlider->usPosY+1), pSlider->usBackGroundColor );
//invalidate the area
InvalidateRegion( pSlider->usPosX, pSlider->usPosY-2, pSlider->usPosX+pSlider->usWidth+1, pSlider->usPosY+2 );
}
RenderSliderBox( pSlider );
}
void RenderSliderBox( SLIDER *pSlider )
{
HVOBJECT hPixHandle;
SGPRect SrcRect;
SGPRect DestRect;
if( pSlider->uiFlags & SLIDER_VERTICAL )
{
//fill out the settings for the current dest and source rects
SrcRect.iLeft = 0;
SrcRect.iTop = 0;
SrcRect.iRight = pSlider->ubSliderWidth;
SrcRect.iBottom = pSlider->ubSliderHeight;
DestRect.iLeft = pSlider->usPosX - pSlider->ubSliderWidth / 2;
DestRect.iTop = pSlider->usCurrentSliderBoxPosition - pSlider->ubSliderHeight/2;
DestRect.iRight = DestRect.iLeft + pSlider->ubSliderWidth;
DestRect.iBottom = DestRect.iTop + pSlider->ubSliderHeight;
//If it is not the first time to render the slider
if( !( pSlider->LastRect.iLeft == 0 && pSlider->LastRect.iRight == 0 ) )
{
//Restore the old rect
BlitBufferToBuffer(guiSAVEBUFFER, guiRENDERBUFFER, (UINT16)pSlider->LastRect.iLeft, (UINT16)pSlider->LastRect.iTop, pSlider->ubSliderWidth, pSlider->ubSliderHeight );
//invalidate the old area
InvalidateRegion( pSlider->LastRect.iLeft, pSlider->LastRect.iTop, pSlider->LastRect.iRight, pSlider->LastRect.iBottom );
}
//Blit the new rect
BlitBufferToBuffer( guiRENDERBUFFER, guiSAVEBUFFER, (UINT16)DestRect.iLeft, (UINT16)DestRect.iTop, pSlider->ubSliderWidth, pSlider->ubSliderHeight );
}
else
{
//fill out the settings for the current dest and source rects
SrcRect.iLeft = 0;
SrcRect.iTop = 0;
SrcRect.iRight = pSlider->ubSliderWidth;
SrcRect.iBottom = pSlider->ubSliderHeight;
DestRect.iLeft = pSlider->usCurrentSliderBoxPosition;
DestRect.iTop = pSlider->usPosY-DEFUALT_SLIDER_SIZE;
DestRect.iRight = DestRect.iLeft + pSlider->ubSliderWidth;
DestRect.iBottom = DestRect.iTop + pSlider->ubSliderHeight;
//If it is not the first time to render the slider
if( !( pSlider->LastRect.iLeft == 0 && pSlider->LastRect.iRight == 0 ) )
{
//Restore the old rect
BlitBufferToBuffer(guiSAVEBUFFER, guiRENDERBUFFER, (UINT16)pSlider->LastRect.iLeft, (UINT16)pSlider->LastRect.iTop, 8, 15 );
}
//save the new rect
BlitBufferToBuffer(guiRENDERBUFFER, guiSAVEBUFFER, (UINT16)DestRect.iLeft, (UINT16)DestRect.iTop, 8, 15 );
}
//Save the new rect location
pSlider->LastRect = DestRect;
if( pSlider->uiFlags & SLIDER_VERTICAL )
{
//display the slider box
GetVideoObject(&hPixHandle, guiSliderBoxImage );
BltVideoObject(FRAME_BUFFER, hPixHandle, 0, pSlider->LastRect.iLeft, pSlider->LastRect.iTop, VO_BLT_SRCTRANSPARENCY,NULL);
//invalidate the area
InvalidateRegion( pSlider->LastRect.iLeft, pSlider->LastRect.iTop, pSlider->LastRect.iRight, pSlider->LastRect.iBottom );
}
else
{
//display the slider box
GetVideoObject(&hPixHandle, guiSliderBoxImage );
BltVideoObject(FRAME_BUFFER, hPixHandle, 0, pSlider->usCurrentSliderBoxPosition, pSlider->usPosY-DEFUALT_SLIDER_SIZE, VO_BLT_SRCTRANSPARENCY,NULL);
//invalidate the area
InvalidateRegion( pSlider->usCurrentSliderBoxPosition, pSlider->usPosY-DEFUALT_SLIDER_SIZE, pSlider->usCurrentSliderBoxPosition+9, pSlider->usPosY+DEFUALT_SLIDER_SIZE );
}
}
void RemoveSliderBar( UINT32 uiSliderID )
{
SLIDER *pTemp = NULL;
SLIDER *pNodeToRemove = NULL;
// UINT32 cnt;
pTemp = pSliderHead;
//Get the required slider
while( pTemp && pTemp->uiSliderID != uiSliderID )
{
pTemp = pTemp->pNext;
}
//if we could not find the required slider
if( pTemp == NULL )
{
//return an error
return;
}
pNodeToRemove = pTemp;
if( pTemp == pSliderHead )
pSliderHead = pSliderHead->pNext;
//Detach the node.
if( pTemp->pNext )
pTemp->pNext->pPrev = pTemp->pPrev;
if( pTemp->pPrev )
pTemp->pPrev->pNext = pTemp->pNext;
MSYS_RemoveRegion( &pNodeToRemove->ScrollAreaMouseRegion );
//if its the last node
if( pNodeToRemove == pSliderHead )
pSliderHead = NULL;
//Remove the slider node
MemFree( pNodeToRemove );
pNodeToRemove = NULL;
}
void SelectedSliderMovementCallBack(MOUSE_REGION * pRegion, INT32 reason )
{
UINT32 uiSelectedSlider;
SLIDER *pSlider=NULL;
//if we already have an anchored slider bar
if( gpCurrentSlider != NULL )
return;
if( reason & MSYS_CALLBACK_REASON_LOST_MOUSE )
{
pRegion->uiFlags &= (~BUTTON_CLICKED_ON );
if( gfLeftButtonState )
{
uiSelectedSlider = MSYS_GetRegionUserData( pRegion, 1 );
pSlider = GetSliderFromID( uiSelectedSlider );
if( pSlider == NULL )
return;
// set the currently selectd slider bar
if( gfLeftButtonState )
{
gpCurrentSlider = pSlider;
}
if( pSlider->uiFlags & SLIDER_VERTICAL )
{
CalculateNewSliderIncrement( uiSelectedSlider, pRegion->RelativeYPos );
}
else
{
CalculateNewSliderIncrement( uiSelectedSlider, pRegion->RelativeXPos );
}
}
}
else if( reason & MSYS_CALLBACK_REASON_GAIN_MOUSE )
{
pRegion->uiFlags |= BUTTON_CLICKED_ON ;
if( gfLeftButtonState )
{
uiSelectedSlider = MSYS_GetRegionUserData( pRegion, 1 );
pSlider = GetSliderFromID( uiSelectedSlider );
if( pSlider == NULL )
return;
// set the currently selectd slider bar
// gpCurrentSlider = pSlider;
if( pSlider->uiFlags & SLIDER_VERTICAL )
{
CalculateNewSliderIncrement( uiSelectedSlider, pRegion->RelativeYPos );
}
else
{
CalculateNewSliderIncrement( uiSelectedSlider, pRegion->RelativeXPos );
}
}
}
else if( reason & MSYS_CALLBACK_REASON_MOVE )
{
pRegion->uiFlags |= BUTTON_CLICKED_ON ;
if( gfLeftButtonState )
{
uiSelectedSlider = MSYS_GetRegionUserData( pRegion, 1 );
pSlider = GetSliderFromID( uiSelectedSlider );
if( pSlider == NULL )
return;
// set the currently selectd slider bar
// gpCurrentSlider = pSlider;
if( pSlider->uiFlags & SLIDER_VERTICAL )
{
CalculateNewSliderIncrement( uiSelectedSlider, pRegion->RelativeYPos );
}
else
{
CalculateNewSliderIncrement( uiSelectedSlider, pRegion->RelativeXPos );
}
}
}
}
void SelectedSliderButtonCallBack(MOUSE_REGION * pRegion, INT32 iReason )
{
UINT32 uiSelectedSlider;
SLIDER *pSlider=NULL;
//if we already have an anchored slider bar
if( gpCurrentSlider != NULL )
return;
if (iReason & MSYS_CALLBACK_REASON_INIT)
{
}
else if (iReason & MSYS_CALLBACK_REASON_LBUTTON_DWN)
{
uiSelectedSlider = MSYS_GetRegionUserData( pRegion, 1 );
pSlider = GetSliderFromID( uiSelectedSlider );
if( pSlider == NULL )
return;
/* // set the currently selectd slider bar
if( gfLeftButtonState )
{
gpCurrentSlider = pSlider;
}
*/
if( pSlider->uiFlags & SLIDER_VERTICAL )
{
CalculateNewSliderIncrement( uiSelectedSlider, pRegion->RelativeYPos );
}
else
{
CalculateNewSliderIncrement( uiSelectedSlider, pRegion->RelativeXPos );
}
}
else if (iReason & MSYS_CALLBACK_REASON_LBUTTON_REPEAT )
{
uiSelectedSlider = MSYS_GetRegionUserData( pRegion, 1 );
pSlider = GetSliderFromID( uiSelectedSlider );
if( pSlider == NULL )
return;
// set the currently selectd slider bar
/* if( gfLeftButtonState )
{
gpCurrentSlider = pSlider;
}
*/
if( pSlider->uiFlags & SLIDER_VERTICAL )
{
CalculateNewSliderIncrement( uiSelectedSlider, pRegion->RelativeYPos );
}
else
{
CalculateNewSliderIncrement( uiSelectedSlider, pRegion->RelativeXPos );
}
}
else if (iReason & MSYS_CALLBACK_REASON_LBUTTON_UP)
{
}
}
void CalculateNewSliderIncrement( UINT32 uiSliderID, UINT16 usPos )
{
FLOAT dNewIncrement=0.0;
SLIDER *pSlider;
UINT16 usOldIncrement;
BOOLEAN fLastSpot=FALSE;
BOOLEAN fFirstSpot=FALSE;
pSlider = GetSliderFromID( uiSliderID );
if( pSlider == NULL )
return;
usOldIncrement = pSlider->usCurrentIncrement;
if( pSlider->uiFlags & SLIDER_VERTICAL )
{
if( usPos >= (UINT16)(pSlider->usHeight * (FLOAT).99 ) )
fLastSpot = TRUE;
if( usPos <= (UINT16)(pSlider->usHeight * (FLOAT).01 ) )
fFirstSpot = TRUE;
//pSlider->usNumberOfIncrements
if( fFirstSpot )
dNewIncrement = 0;
else if( fLastSpot )
dNewIncrement = pSlider->usNumberOfIncrements;
else
dNewIncrement = ( usPos / (FLOAT)pSlider->usHeight ) * pSlider->usNumberOfIncrements;
}
else
{
dNewIncrement = ( usPos / (FLOAT)pSlider->usWidth ) * pSlider->usNumberOfIncrements;
}
pSlider->usCurrentIncrement = (UINT16)( dNewIncrement + .5 );
CalculateNewSliderBoxPosition( pSlider );
//if the the new value is different
if( usOldIncrement != pSlider->usCurrentIncrement )
{
if( pSlider->uiFlags & SLIDER_VERTICAL )
{
//Call the call back for the slider
(*(pSlider->SliderChangeCallback) )( pSlider->usNumberOfIncrements - pSlider->usCurrentIncrement );
}
else
{
//Call the call back for the slider
(*(pSlider->SliderChangeCallback) )( pSlider->usCurrentIncrement );
}
}
}
void OptDisplayLine( UINT16 usStartX, UINT16 usStartY, UINT16 EndX, UINT16 EndY, INT16 iColor )
{
UINT32 uiDestPitchBYTES;
UINT8 *pDestBuf;
pDestBuf = LockVideoSurface( FRAME_BUFFER, &uiDestPitchBYTES );
SetClippingRegionAndImageWidth( uiDestPitchBYTES, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
// draw the line
LineDraw(FALSE, usStartX, usStartY, EndX, EndY, iColor, pDestBuf);
// unlock frame buffer
UnLockVideoSurface( FRAME_BUFFER );
}
void CalculateNewSliderBoxPosition( SLIDER *pSlider )
{
UINT16 usMaxPos;
if( pSlider->uiFlags & SLIDER_VERTICAL )
{
//if the box is in the last position
if( pSlider->usCurrentIncrement >= ( pSlider->usNumberOfIncrements ) )
{
pSlider->usCurrentSliderBoxPosition = pSlider->usPosY + pSlider->usHeight;// - pSlider->ubSliderHeight / 2; // - minus box width
}
//else if the box is in the first position
else if( pSlider->usCurrentIncrement == 0 )
{
pSlider->usCurrentSliderBoxPosition = pSlider->usPosY;// - pSlider->ubSliderHeight / 2;
}
else
{
pSlider->usCurrentSliderBoxPosition = pSlider->usPosY + (UINT16)( ( pSlider->usHeight / (FLOAT)pSlider->usNumberOfIncrements ) * pSlider->usCurrentIncrement );
}
usMaxPos = pSlider->usPosY + pSlider->usHeight;// - pSlider->ubSliderHeight//2 + 1;
//if the box is past the edge, move it back
if( pSlider->usCurrentSliderBoxPosition > usMaxPos )
pSlider->usCurrentSliderBoxPosition = usMaxPos;
}
else
{
//if the box is in the last position
if( pSlider->usCurrentIncrement == ( pSlider->usNumberOfIncrements ) )
{
pSlider->usCurrentSliderBoxPosition = pSlider->usPosX + pSlider->usWidth - 8 + 1; // - minus box width
}
else
{
pSlider->usCurrentSliderBoxPosition = pSlider->usPosX + (UINT16)( ( pSlider->usWidth / (FLOAT)pSlider->usNumberOfIncrements ) * pSlider->usCurrentIncrement );
}
usMaxPos = pSlider->usPosX + pSlider->usWidth - 8+1;
//if the box is past the edge, move it back
if( pSlider->usCurrentSliderBoxPosition > usMaxPos )
pSlider->usCurrentSliderBoxPosition = usMaxPos;
}
}
SLIDER *GetSliderFromID( UINT32 uiSliderID )
{
SLIDER *pTemp = NULL;
pTemp = pSliderHead;
//Get the required slider
while( pTemp && pTemp->uiSliderID != uiSliderID )
{
pTemp = pTemp->pNext;
}
// if we couldnt find the right slider
if( pTemp == NULL )
return( NULL );
return( pTemp );
}
void SetSliderValue( UINT32 uiSliderID, UINT32 uiNewValue )
{
SLIDER *pSlider = NULL;
pSlider = GetSliderFromID( uiSliderID );
if( pSlider == NULL )
return;
if( uiNewValue >= pSlider->usNumberOfIncrements )
return;
if( pSlider->uiFlags & SLIDER_VERTICAL )
pSlider->usCurrentIncrement = pSlider->usNumberOfIncrements - (UINT16)uiNewValue;
else
pSlider->usCurrentIncrement = (UINT16)uiNewValue;
CalculateNewSliderBoxPosition( pSlider );
}
+63
View File
@@ -0,0 +1,63 @@
#ifndef _SLIDER__H_
#define _SLIDER__H_
#define SLIDER_VERTICAL 0x00000001
#define SLIDER_HORIZONTAL 0x00000002
//defines for the different styles of sliders
enum
{
SLIDER_DEFAULT_STYLE,
SLIDER_VERTICAL_STEEL,
NUM_SLIDER_STYLES,
};
typedef void ( *SLIDER_CHANGE_CALLBACK ) (INT32);
/*
ubStyle
usPosX
usPosY
usWidth
usNumberOfIncrements
sPriority
SliderChangeCallback
void SliderChangeCallBack( INT32 iNewValue )
*/
INT32 AddSlider( UINT8 ubStyle, UINT16 usCursor, UINT16 usPosX, UINT16 usPosY, UINT16 usWidth, UINT16 usNumberOfIncrements, INT8 sPriority, SLIDER_CHANGE_CALLBACK SliderChangeCallback, UINT32 uiFlags );
BOOLEAN InitSlider();
void ShutDownSlider();
void RenderAllSliderBars();
void RemoveSliderBar( UINT32 uiSliderID );
void SetSliderValue( UINT32 uiSliderID, UINT32 uiNewValue );
#endif
File diff suppressed because it is too large Load Diff
+462
View File
@@ -0,0 +1,462 @@
#ifndef SOUND_CONTROL_H
#define SOUND_CONTROL_H
#define FARLEFT 0
#define LEFTSIDE 48
#define MIDDLE 64
#define MIDDLEPAN 64
#define RIGHTSIDE 80
#define FARRIGHT 127
#define LOWVOLUME 25
#define BTNVOLUME 40
#define MIDVOLUME 65
#define HIGHVOLUME 127
#define RATE_11025 0xffffffff
#define LOOPING 0
// sound group priorities (higher = more important)
#define GROUP_PLAYER 1000
#define GROUP_AMBIENT 0
#define MAX_SAMPLES 5000
// SOUNDS ENUMERATION
enum SoundDefines
{
MISS_1 = 0,
MISS_2,
MISS_3,
MISS_4,
MISS_5,
MISS_6,
MISS_7,
MISS_8,
MISS_G1,
MISS_G2,
MISS_KNIFE,
FALL_1,
FALL_2,
FALL_TO_GROUND_1,
FALL_TO_GROUND_2,
FALL_TO_GROUND_3,
HEAVY_FALL_1,
BODY_SPLAT_1,
GLASS_SHATTER1,
GLASS_SHATTER2,
DROPEN_1,
DROPEN_2,
DROPEN_3,
DRCLOSE_1,
DRCLOSE_2,
UNLOCK_DOOR_1,
KICKIN_DOOR,
BREAK_LOCK,
PICKING_LOCK,
GARAGE_DOOR_OPEN,
GARAGE_DOOR_CLOSE,
ELEVATOR_DOOR_OPEN,
ELEVATOR_DOOR_CLOSE,
HITECH_DOOR_OPEN,
HITECH_DOOR_CLOSE,
CURTAINS_OPEN,
CURTAINS_CLOSE,
METAL_DOOR_OPEN,
METAL_DOOR_CLOSE,
WALK_LEFT_OUT,
WALK_RIGHT_OUT,
WALK_LEFT_OUT2,
WALK_RIGHT_OUT2,
WALK_LEFT_IN,
WALK_RIGHT_IN,
WALK_LEFT_IN2,
WALK_RIGHT_IN2,
WALK_LEFT_ROAD,
WALK_RIGHT_ROAD,
WALK_LEFT_ROAD2,
WALK_RIGHT_ROAD2,
CRAWL_1,
CRAWL_2,
CRAWL_3,
CRAWL_4,
TARG_REFINE_BEEP,
ENDTURN_1,
HEADCR_1,
DOORCR_1,
HEADSPLAT_1,
BODY_EXPLODE_1,
EXPLOSION_1,
CROW_EXPLODE_1,
SMALL_EXPLODE_1,
HELI_1,
BULLET_IMPACT_1,
BULLET_IMPACT_2,
BULLET_IMPACT_3,
CREATURE_BATTLECRY_1,
ENTER_WATER_1,
ENTER_DEEP_WATER_1,
COW_HIT_SND,
COW_DIE_SND,
// ROCKET GUN COMPUTER VOICE...
RG_ID_IMPRINTED,
RG_ID_INVALID,
RG_TARGET_SELECTED,
// CAVE COLLAPSE
CAVE_COLLAPSE,
// AIR RAID SOUNDS...
S_RAID_WHISTLE,
S_RAID_AMBIENT,
S_RAID_DIVE,
S_RAID_TB_DIVE,
S_RAID_TB_BOMB,
// VEHICLE SOUNDS
S_VECH1_MOVE,
S_VECH1_ON,
S_VECH1_OFF,
S_VECH1_INTO,
S_DRYFIRE1,
// IMPACT SOUNDS
S_WOOD_IMPACT1,
S_WOOD_IMPACT2,
S_WOOD_IMPACT3,
S_PORCELAIN_IMPACT1,
S_RUBBER_IMPACT1,
S_STONE_IMPACT1,
S_WATER_IMPACT1,
S_VEG_IMPACT1,
S_METAL_IMPACT1,
S_METAL_IMPACT2,
S_METAL_IMPACT3,
S_SLAP_IMPACT,
// WEAPON RELOAD
S_RELOAD_REVOLVER,
S_RELOAD_PISTOL,
S_RELOAD_SMG,
S_RELOAD_RIFLE,
S_RELOAD_SHOTGUN,
S_RELOAD_LMG,
// WEAPON LOCKNLOAD
S_LNL_REVOLVER,
S_LNL_PISTOL,
S_LNL_SMG,
S_LNL_RIFLE,
S_LNL_SHOTGUN,
S_LNL_LMG,
//WEAPON SHOT SOUNDS
S_SMALL_ROCKET_LAUNCHER,
S_GLAUNCHER,
S_UNDER_GLAUNCHER,
S_ROCKET_LAUNCHER,
S_MORTAR_SHOT,
S_GLOCK17,
S_GLOCK18,
S_BERETTA92,
S_BERETTA93,
S_SWSPECIAL,
S_BARRACUDA,
S_DESERTEAGLE,
S_M1911,
S_MP5K,
S_MAC10,
S_THOMPSON,
S_COMMANDO,
S_MP53,
S_AKSU74,
S_P90,
S_TYPE85,
S_SKS,
S_DRAGUNOV,
S_M24,
S_AUG,
S_G41,
S_RUGERMINI,
S_C7,
S_FAMAS,
S_AK74,
S_AKM,
S_M14,
S_FNFAL,
S_G3A3,
S_G11,
S_M870,
S_SPAS,
S_CAWS,
S_FNMINI,
S_RPK74,
S_21E,
S_THROWKNIFE,
S_TANK_CANNON,
S_BURSTTYPE1,
S_AUTOMAG,
S_SILENCER_1,
S_SILENCER_2,
// SWOOSHES.
SWOOSH_1,
SWOOSH_2,
SWOOSH_3,
SWOOSH_4,
SWOOSH_5,
SWOOSH_6,
// CREATURE SOUNDS....
ACR_FALL_1,
ACR_STEP_1,
ACR_STEP_2,
ACR_SWIPE,
ACR_EATFLESH,
ACR_CRIPPLED,
ACR_DIE_PART1,
ACR_DIE_PART2,
ACR_LUNGE,
ACR_SMELL_THREAT,
ACR_SMEEL_PREY,
ACR_SPIT,
//BABY
BCR_DYING,
BCR_DRAGGING,
BCR_SHRIEK,
BCR_SPITTING,
// LARVAE
LCR_MOVEMENT,
LCR_RUPTURE,
// QUEEN
LQ_SHRIEK,
LQ_DYING,
LQ_ENRAGED_ATTACK,
LQ_RUPTURING,
LQ_CRIPPLED,
LQ_SMELLS_THREAT,
LQ_WHIP_ATTACK,
THROW_IMPACT_1,
THROW_IMPACT_2,
IDLE_SCRATCH,
IDLE_ARMPIT,
IDLE_BACKCRACK,
AUTORESOLVE_FINISHFX,
//Interface buttons, misc.
EMAIL_ALERT,
ENTERING_TEXT,
REMOVING_TEXT,
COMPUTER_BEEP2_IN,
COMPUTER_BEEP2_OUT,
COMPUTER_SWITCH1_IN,
COMPUTER_SWITCH1_OUT,
VSM_SWITCH1_IN,
VSM_SWITCH1_OUT,
VSM_SWITCH2_IN,
VSM_SWITCH2_OUT,
SM_SWITCH1_IN,
SM_SWITCH1_OUT,
SM_SWITCH2_IN,
SM_SWITCH2_OUT,
SM_SWITCH3_IN,
SM_SWITCH3_OUT,
BIG_SWITCH3_IN,
BIG_SWITCH3_OUT,
KLAXON_ALARM,
BOXING_BELL,
HELI_CRASH,
ATTACH_TO_GUN,
ATTACH_CERAMIC_PLATES,
ATTACH_DETONATOR,
GRAB_ROOF,
LAND_ON_ROOF,
UNSTEALTHY_OUTSIDE_1,
UNSTEALTHY_OUTSIDE_2,
UNSTEALTHY_INSIDE_1,
OPEN_DEFAULT_OPENABLE,
CLOSE_DEFAULT_OPENABLE,
FIRE_ON_MERC,
GLASS_CRACK,
SPIT_RICOCHET,
BLOODCAT_HIT_1,
BLOODCAT_DIE_1,
SLAP_1,
ROBOT_BEEP,
DOOR_ELECTRICITY,
SWIM_1,
SWIM_2,
KEY_FAILURE,
TARGET_OUT_OF_RANGE,
OPEN_STATUE,
USE_STATUE_REMOTE,
USE_WIRE_CUTTERS,
DRINK_CANTEEN_FEMALE,
BLOODCAT_ATTACK,
BLOODCAT_ROAR,
ROBOT_GREETING,
ROBOT_DEATH,
GAS_EXPLODE_1,
AIR_ESCAPING_1,
OPEN_DRAWER,
CLOSE_DRAWER,
OPEN_LOCKER,
CLOSE_LOCKER,
OPEN_WOODEN_BOX,
CLOSE_WOODEN_BOX,
ROBOT_STOP,
WATER_WALK1_IN,
WATER_WALK1_OUT,
WATER_WALK2_IN,
WATER_WALK2_OUT,
PRONE_UP_SOUND,
PRONE_DOWN_SOUND,
KNEEL_UP_SOUND,
KNEEL_DOWN_SOUND,
PICKING_SOMETHING_UP,
COW_FALL,
BLOODCAT_GROWL_1,
BLOODCAT_GROWL_2,
BLOODCAT_GROWL_3,
BLOODCAT_GROWL_4,
CREATURE_GAS_NOISE,
CREATURE_FALL_PART_2,
CREATURE_DISSOLVE_1,
QUEEN_AMBIENT_NOISE,
CREATURE_FALL,
CROW_PECKING_AT_FLESH,
CROW_FLYING_AWAY,
SLAP_2,
MORTAR_START,
MORTAR_WHISTLE,
MORTAR_LOAD,
TURRET_MOVE,
TURRET_STOP,
COW_FALL_2,
KNIFE_IMPACT,
EXPLOSION_ALT_BLAST_1,
EXPLOSION_BLAST_2,
DRINK_CANTEEN_MALE,
USE_X_RAY_MACHINE,
CATCH_OBJECT,
FENCE_OPEN,
//MADD MARKER
S_BARRETT,
S_VAL,
// BREAK_LIGHT_IGNITING,
NUM_SAMPLES
};
enum AmbientDefines
{
LIGHTNING_1 = 0,
LIGHTNING_2,
RAIN_1,
BIRD_1,
BIRD_2,
CRICKETS_1,
CRICKETS_2,
CRICKET_1,
CRICKET_2,
OWL_1,
OWL_2,
OWL_3,
NIGHT_BIRD_1,
NIGHT_BIRD_2,
NUM_AMBIENTS
};
typedef void (*SOUND_STOP_CALLBACK)( void *pData );
extern UINT8 AmbientVols[NUM_AMBIENTS];
extern char szSoundEffects[MAX_SAMPLES][255];
BOOLEAN InitJA2Sound( );
BOOLEAN ShutdownJA2Sound( );
UINT32 PlayJA2Sample( UINT32 usNum, UINT32 usRate, UINT32 ubVolume, UINT32 ubLoops, UINT32 uiPan );
UINT32 PlayJA2StreamingSample( UINT32 usNum, UINT32 usRate, UINT32 ubVolume, UINT32 ubLoops, UINT32 uiPan );
UINT32 PlayJA2SampleFromFile( STR8 szFileName, UINT32 usRate, UINT32 ubVolume, UINT32 ubLoops, UINT32 uiPan );
UINT32 PlayJA2StreamingSampleFromFile( STR8 szFileName, UINT32 usRate, UINT32 ubVolume, UINT32 ubLoops, UINT32 uiPan, SOUND_STOP_CALLBACK EndsCallback );
UINT32 PlayJA2Ambient( UINT32 usNum, UINT32 ubVolume, UINT32 ubLoops);
UINT32 PlayJA2AmbientRandom(UINT32 usNum, UINT32 uiTimeMin, UINT32 uiTimeMax);
UINT32 PlaySoldierJA2Sample( UINT16 usID, UINT32 usNum, UINT32 usRate, UINT32 ubVolume, UINT32 ubLoops, UINT32 uiPan, BOOLEAN fCheck );
UINT32 GetSoundEffectsVolume( );
void SetSoundEffectsVolume( UINT32 uiNewVolume );
UINT32 GetSpeechVolume( );
void SetSpeechVolume( UINT32 uiNewVolume );
//Calculates a volume based on the current Speech Volume level
UINT32 CalculateSpeechVolume( UINT32 uiVolume );
//Calculates a volume based on the current Sound Effects Volume level
UINT32 CalculateSoundEffectsVolume( UINT32 uiVolume );
INT8 SoundDir( INT16 sGridNo );
INT8 SoundVolume( INT8 bInitialVolume, INT16 sGridNo );
// ATE: Warning! Use this sparingly! NOT very robust - can
// have only 1 delayed sound at a time, and uses the global custom
// timer, again, of which can only be one
void PlayDelayedJA2Sample( UINT32 uiDelay, UINT32 usNum, UINT32 usRate, UINT32 ubVolume, UINT32 ubLoops, UINT32 uiPan );
#define POSITION_SOUND_FROM_SOLDIER 0x00000001
#define POSITION_SOUND_STATIONATY_OBJECT 0x00000002
INT32 NewPositionSnd( INT16 sGridNo, UINT32 uiFlags, UINT32 uiData, UINT32 iSoundToPlay );
void DeletePositionSnd( INT32 iPositionSndIndex );
void SetPositionSndsActive( );
void SetPositionSndsInActive( );
void SetPositionSndsVolumeAndPanning( );
void SetPositionSndGridNo( INT32 iPositionSndIndex, INT16 sGridNo );
#endif
+1764
View File
File diff suppressed because it is too large Load Diff
+195
View File
@@ -0,0 +1,195 @@
#ifndef __TEXT_INPUT_H
#define __TEXT_INPUT_H
#include "input.h"
//AUTHOR: Kris Morness
//Intended for inclusion with SGP.
//NEW CHANGES: January 16, 1998
//I have added the ability to stack the text input modes. So, if you have a particular
//screen that has fields, then somehow, hit a key to go into another mode with text input,
//it will automatically disable the current fields, as you go on to define new ones. Previously,
//you would have to make sure the mode was removed before initializing a new one. There were
//potential side effects of crashes, and unpredictable results, as the new fields would cook the
//existing ones.
//NOTE: You may have to modify you code now, so that you don't accidentally kill a text input mode
//when you don't one to begin with. (like removing an already deleted button). Also, remember that
//this works like a stack system and you can't flip through existing defined text input modes at will.
//NOTES ON LIMITATIONS:
// -max number of fields 255 (per level)
// -max num of chars in field 255
//These are the definitions for the input types. I didn't like the input filter idea,
//and the lack of freedom it gives you. This method is much simpler to use.
//NOTE: Uppercase/lowercase filters ensures that all input is either all uppercase or lowercase
//NOTE: Feel free to expand this to your needs, though you also need to support it in the filter
// section.
#define INPUTTYPE_NUMERICSTRICT 0x0001 //0-9 only, no minus signs.
#define INPUTTYPE_ALPHA 0x0002 //a-z A-Z
#define INPUTTYPE_SPACES 0x0004 //allows spaces in input
#define INPUTTYPE_SPECIAL 0x0008 // !@#$%^&*()_+`|\[]{};':"<>,./? (spaces not included)
#define INPUTTYPE_UPPERCASE 0x0010 //converts all lowercase to uppercase
#define INPUTTYPE_LOWERCASE 0x0020 //converts all uppercase to lowercase
#define INPUTTYPE_FIRSTPOSMINUS 0x0002 //allows '-' at beginning of field only
#define INPUTTYPE_NUMERIC (INPUTTYPE_NUMERIC | INPUTTYPE_FIRSTPOSMINUS )
#define INPUTTYPE_SPECIALCHARS (INPUTTYPE_SPECIAL | INPUTTYPE_SPACES)
#define INPUTTYPE_ALPHANUMERIC (INPUTTYPE_ALPHA | INPUTTYPE_NUMERICSTRICT)
#define INPUTTYPE_ASCII (INPUTTYPE_ALPHANUMERIC | INPUTTYPE_SPECIALCHARS)
//DON'T GO ABOVE INPUTTYPE_EXCLUSIVE_BASEVALUE FOR INPUTTYPE MASKED VALUES LISTED ABOVE!!!
#define INPUTTYPE_EXCLUSIVE_BASEVALUE 0x1000 //increase this value if necessary
//Exclusive handlers
//The dosfilename inputtype is a perfect example of what is a exclusive handler.
//In this method, the input accepts only alphas and an underscore as the first character,
//then alphanumerics afterwards. For further support, chances are you'll want to treat it
//as an exclusive handler, and you'll have to process it in the filter input function.
enum
{
INPUTTYPE_EXCLUSIVE_DOSFILENAME = INPUTTYPE_EXCLUSIVE_BASEVALUE,
INPUTTYPE_EXCLUSIVE_COORDINATE,
INPUTTYPE_EXCLUSIVE_24HOURCLOCK,
//INPUTTYPE_EXCLUSIVE_NEWNEWNEW, etc...
};
//Simply initiates that you wish to begin inputting text. This should only apply to screen
//initializations that contain fields that edit text. It also verifies and clears any existing
//fields. Your input loop must contain the function HandleTextInput and processed if the gfTextInputMode
//flag is set else process your regular input handler. Note that this doesn't mean you are necessarily typing,
//just that there are text fields in your screen and may be inactive. The TAB key cycles through your text fields,
//and special fields can be defined which will call a void functionName( UINT16 usFieldNum )
void InitTextInputMode();
//A hybrid version of InitTextInput() which uses a specific scheme. JA2's editor uses scheme 1, so
//feel free to add new color/font schemes.
enum{
DEFAULT_SCHEME
};
void InitTextInputModeWithScheme( UINT8 ubSchemeID );
//Clears any existing fields, and ends text input mode.
void KillTextInputMode();
//Kills all levels of text input modes. When you init a second consecutive text input mode, without
//first removing them, the existing mode will be preserved. This function removes all of them in one
//call, though doing so "may" reflect poor coding style, though I haven't thought about any really
//just uses for it :(
void KillAllTextInputModes();
//Saves the current text input mode, then removes it and activates the previous text input mode,
//if applicable. The second function restores the settings. Doesn't currently support nested
//calls.
void SaveAndRemoveCurrentTextInputMode();
void RestoreSavedTextInputMode();
void SetTextInputCursor( UINT16 usNewCursor );
UINT16 GetTextInputCursor();
//After calling InitTextInputMode, you want to define one or more text input fields. The order
//of calls to this function dictate the TAB order from traversing from one field to the next. This
//function adds mouse regions and processes them for you, as well as deleting them when you are done.
void AddTextInputField( INT16 sLeft, INT16 sTop, INT16 sWidth, INT16 sHeight, INT8 bPriority,
UINT16 *szInitText, UINT8 ubMaxChars, UINT16 usInputType );
//This allows you to insert special processing functions and modes that can't be determined here. An example
//would be a file dialog where there would be a file list. This file list would be accessed using the Win95
//convention by pressing TAB. In there, your key presses would be handled differently and by adding a userinput
//field, you can make this hook into your function to accomplish this. In a filedialog, alpha characters
//would be used to jump to the file starting with that letter, and setting the field in the text input
//field. Pressing TAB again would place you back in the text input field. All of that stuff would be handled
//externally, except for the TAB keys.
typedef void (*INPUT_CALLBACK)(UINT8,BOOLEAN);
void AddUserInputField( INPUT_CALLBACK userFunction );
//INPUT_CALLBACK explanation:
//The function must use this signature: void FunctionName( UINT8 ubFieldID, BOOLEAN fEntering );
//ubFieldID contains the fieldID of that field
//fEntering is true if you are entering the user field, false if exiting.
//Removes the specified field from the existing fields. If it doesn't exist, then there will be an
//assertion failure.
void RemoveTextInputField( UINT8 ubField );
//This is a useful call made from an external user input field. Using the previous file dialog example, this
//call would be made when the user selected a different filename in the list via clicking or scrolling with
//the arrows, or even using alpha chars to jump to the appropriate filename.
void SetInputFieldStringWith16BitString( UINT8 ubField, UINT16 *szNewText );
void SetInputFieldStringWith8BitString( UINT8 ubField, UINT8 * szNewText );
//Allows external functions to access the strings within the fields at anytime.
void Get8BitStringFromField( UINT8 ubField, UINT8 *szString );
void Get16BitStringFromField( UINT8 ubField, UINT16 *szString );
//Utility functions for the INPUTTYPE_EXCLUSIVE_24HOURCLOCK input type.
UINT16 GetExclusive24HourTimeValueFromField( UINT8 ubField );
void SetExclusive24HourTimeValue( UINT8 ubField, UINT16 usTime );
//Converts the field's string into a number, then returns that number
//returns -1 if blank or invalid. Only works for positive numbers.
INT32 GetNumericStrictValueFromField( UINT8 ubField );
//Converts a number to a numeric strict value. If the number is negative, the
//field will be blank.
void SetInputFieldStringWithNumericStrictValue( UINT8 ubField, INT32 iNumber );
//Sets the active field to the specified ID number.
void SetActiveField( UINT8 ubField );
void SelectNextField();
void SelectPrevField();
//Returns the active field ID number. It'll return -1 if no field is active.
INT16 GetActiveFieldID();
//These allow you to customize the general color scheme of your text input boxes. I am assuming that
//under no circumstances would a user want a different color for each field. It follows the Win95 convention
//that all text input boxes are exactly the same color scheme. However, these colors can be set at anytime,
//but will effect all of the colors.
void SetTextInputFont( UINT16 usFont );
void Set16BPPTextFieldColor( UINT16 usTextFieldColor );
void SetTextInputRegularColors( UINT8 ubForeColor, UINT8 ubShadowColor );
void SetTextInputHilitedColors( UINT8 ubForeColor, UINT8 ubShadowColor, UINT8 ubBackColor );
//optional color setups
void SetDisabledTextFieldColors( UINT8 ubForeColor, UINT8 ubShadowColor, UINT16 usTextFieldColor );
void SetBevelColors( UINT16 usBrighterColor, UINT16 usDarkerColor );
void SetCursorColor( UINT16 usCursorColor );
//All CTRL and ALT keys combinations, F1-F12 keys, ENTER and ESC are ignored allowing
//processing to be done with your own input handler. Otherwise, the keyboard event
//is absorbed by this input handler, if used in the appropriate manner.
//This call must be added at the beginning of your input handler in this format:
//while( DequeueEvent(&Event) )
//{
// if( !HandleTextInput( &Event ) && (your conditions...ex: Event.usEvent == KEY_DOWN ) )
// {
// switch( Event.usParam )
// {
// //Normal key cases here.
// }
// }
//}
//It is only necessary for event loops that contain text input fields.
BOOLEAN HandleTextInput( InputAtom *Event );
//Required in your screen loop to update the values, as well as blinking the cursor.
void RenderActiveTextField();
void RenderInactiveTextField( UINT8 ubID );
void RenderAllTextFields();
void EnableTextField( UINT8 ubID );
void DisableTextField( UINT8 ubID );
void EnableTextFields( UINT8 ubFirstID, UINT8 ubLastID );
void DisableTextFields( UINT8 ubFirstID, UINT8 ubLastID );
void EnableAllTextFields();
void DisableAllTextFields();
//
BOOLEAN EditingText();
BOOLEAN TextInputMode();
void InitClipboard();
void KillClipboard();
extern BOOLEAN gfNoScroll;
#endif
+312
View File
@@ -0,0 +1,312 @@
#ifdef PRECOMPILEDHEADERS
#include "Utils All.h"
#else
#include "Language Defines.h"
#include "text.h"
#include "Fileman.h"
#endif
BOOLEAN LoadItemInfo(UINT16 ubIndex, STR16 pNameString, STR16 pInfoString )
{
//HWFILE hFile;
//UINT32 uiBytesRead;
//UINT16 i;
//UINT32 uiStartSeekAmount;
// DebugMsg(TOPIC_JA2, DBG_LEVEL_3,String("LoadItemInfo"));
for (int i=0;i<80;i++)
{
if ( i<(int)strlen(Item[ubIndex].szLongItemName ))
pNameString[i] = Item[ubIndex].szLongItemName [i];
else
pNameString[i] ='\0';
}
if(pInfoString != NULL)
{
for (int i=0;i<400;i++)
{
if ( i<(int)strlen(Item[ubIndex].szItemDesc ))
pInfoString[i] = Item[ubIndex].szItemDesc [i];
else
pInfoString[i] ='\0';
}
}
/*
hFile = FileOpen(ITEMSTRINGFILENAME, FILE_ACCESS_READ, FALSE);
if ( !hFile )
{
return( FALSE );
}
// Get current mercs bio info
uiStartSeekAmount = ( ( SIZE_SHORT_ITEM_NAME + SIZE_ITEM_NAME + SIZE_ITEM_INFO) * ubIndex );
// Skip short names
uiStartSeekAmount += SIZE_SHORT_ITEM_NAME;
if ( FileSeek( hFile, uiStartSeekAmount, FILE_SEEK_FROM_START ) == FALSE )
{
FileClose(hFile);
return( FALSE );
}
if( !FileRead( hFile, pNameString, SIZE_ITEM_NAME, &uiBytesRead) )
{
FileClose(hFile);
return( FALSE );
}
DebugMsg(TOPIC_JA2, DBG_LEVEL_3,String("LoadItemInfo: pNameString file read = %s",pNameString));
// Decrement, by 1, any value > 32
for(i=0; (i<SIZE_ITEM_NAME) && (pNameString[i] != 0); i++ )
{
if( pNameString[i] > 33 )
pNameString[i] -= 1;
#ifdef POLISH
switch( pNameString[ i ] )
{
case 260: pNameString[ i ] = 165; break;
case 262: pNameString[ i ] = 198; break;
case 280: pNameString[ i ] = 202; break;
case 321: pNameString[ i ] = 163; break;
case 323: pNameString[ i ] = 209; break;
case 211: pNameString[ i ] = 211; break;
case 346: pNameString[ i ] = 338; break;
case 379: pNameString[ i ] = 175; break;
case 377: pNameString[ i ] = 143; break;
case 261: pNameString[ i ] = 185; break;
case 263: pNameString[ i ] = 230; break;
case 281: pNameString[ i ] = 234; break;
case 322: pNameString[ i ] = 179; break;
case 324: pNameString[ i ] = 241; break;
case 243: pNameString[ i ] = 243; break;
case 347: pNameString[ i ] = 339; break;
case 380: pNameString[ i ] = 191; break;
case 378: pNameString[ i ] = 376; break;
}
#endif
}
DebugMsg(TOPIC_JA2, DBG_LEVEL_3,String("LoadItemInfo: pNameString after decrement = %s",pNameString));
DebugMsg(TOPIC_JA2, DBG_LEVEL_3,String("LoadItemInfo: pNameString after decrement = %s",pNameString+1));
DebugMsg(TOPIC_JA2, DBG_LEVEL_3,String("LoadItemInfo: pNameString after decrement = %s",pNameString+2));
DebugMsg(TOPIC_JA2, DBG_LEVEL_3,String("LoadItemInfo: pNameString after decrement = %s",pNameString+3));
// condition added by Chris - so we can get the name without the item info
// when desired, by passing in a null pInfoString
if (pInfoString != NULL)
{
// Get the additional info
uiStartSeekAmount = ((SIZE_ITEM_NAME + SIZE_SHORT_ITEM_NAME + SIZE_ITEM_INFO) * ubIndex ) + SIZE_ITEM_NAME + SIZE_SHORT_ITEM_NAME;
if ( FileSeek( hFile, uiStartSeekAmount, FILE_SEEK_FROM_START ) == FALSE )
{
FileClose(hFile);
return( FALSE );
}
if( !FileRead( hFile, pInfoString, SIZE_ITEM_INFO, &uiBytesRead) )
{
FileClose(hFile);
return( FALSE );
}
// Decrement, by 1, any value > 32
for(i=0; (i<SIZE_ITEM_INFO) && (pInfoString[i] != 0); i++ )
{
if( pInfoString[i] > 33 )
pInfoString[i] -= 1;
#ifdef POLISH
switch( pInfoString[ i ] )
{
case 260: pInfoString[ i ] = 165; break;
case 262: pInfoString[ i ] = 198; break;
case 280: pInfoString[ i ] = 202; break;
case 321: pInfoString[ i ] = 163; break;
case 323: pInfoString[ i ] = 209; break;
case 211: pInfoString[ i ] = 211; break;
case 346: pInfoString[ i ] = 338; break;
case 379: pInfoString[ i ] = 175; break;
case 377: pInfoString[ i ] = 143; break;
case 261: pInfoString[ i ] = 185; break;
case 263: pInfoString[ i ] = 230; break;
case 281: pInfoString[ i ] = 234; break;
case 322: pInfoString[ i ] = 179; break;
case 324: pInfoString[ i ] = 241; break;
case 243: pInfoString[ i ] = 243; break;
case 347: pInfoString[ i ] = 339; break;
case 380: pInfoString[ i ] = 191; break;
case 378: pInfoString[ i ] = 376; break;
}
#endif
}
}
FileClose(hFile);
*/
return(TRUE);
}
BOOLEAN LoadBRName(UINT16 ubIndex, STR16 pNameString )
{
for (int i=0;i<80;i++)
{
if ( i<(int)strlen(Item[ubIndex].szBRName))
pNameString[i] = Item[ubIndex].szBRName [i];
else
pNameString[i] ='\0';
}
return TRUE;
}
BOOLEAN LoadBRDesc(UINT16 ubIndex, STR16 pDescString )
{
for (int i=0;i<400;i++)
{
if ( i<(int)strlen(Item[ubIndex].szBRDesc))
pDescString[i] = Item[ubIndex].szBRDesc [i];
else
pDescString[i] ='\0';
}
return TRUE;
}
BOOLEAN LoadShortNameItemInfo(UINT16 ubIndex, STR16 pNameString )
{
for (int i=0;i<80;i++)
{
if ( i<(int)strlen(Item[ubIndex].szItemName))
pNameString[i] = Item[ubIndex].szItemName [i];
else
pNameString[i] ='\0';
}
/*
HWFILE hFile;
// wchar_t DestString[ SIZE_MERC_BIO_INFO ];
UINT32 uiBytesRead;
UINT16 i;
UINT32 uiStartSeekAmount;
hFile = FileOpen(ITEMSTRINGFILENAME, FILE_ACCESS_READ, FALSE);
if ( !hFile )
{
return( FALSE );
}
// Get current mercs bio info
uiStartSeekAmount = ( ( SIZE_SHORT_ITEM_NAME + SIZE_ITEM_NAME + SIZE_ITEM_INFO ) * ubIndex );
if ( FileSeek( hFile, uiStartSeekAmount, FILE_SEEK_FROM_START ) == FALSE )
{
FileClose(hFile);
return( FALSE );
}
if( !FileRead( hFile, pNameString, SIZE_ITEM_NAME, &uiBytesRead) )
{
FileClose(hFile);
return( FALSE );
}
// Decrement, by 1, any value > 32
for(i=0; (i<SIZE_ITEM_NAME) && (pNameString[i] != 0); i++ )
{
if( pNameString[i] > 33 )
pNameString[i] -= 1;
#ifdef POLISH
switch( pNameString[ i ] )
{
case 260: pNameString[ i ] = 165; break;
case 262: pNameString[ i ] = 198; break;
case 280: pNameString[ i ] = 202; break;
case 321: pNameString[ i ] = 163; break;
case 323: pNameString[ i ] = 209; break;
case 211: pNameString[ i ] = 211; break;
case 346: pNameString[ i ] = 338; break;
case 379: pNameString[ i ] = 175; break;
case 377: pNameString[ i ] = 143; break;
case 261: pNameString[ i ] = 185; break;
case 263: pNameString[ i ] = 230; break;
case 281: pNameString[ i ] = 234; break;
case 322: pNameString[ i ] = 179; break;
case 324: pNameString[ i ] = 241; break;
case 243: pNameString[ i ] = 243; break;
case 347: pNameString[ i ] = 339; break;
case 380: pNameString[ i ] = 191; break;
case 378: pNameString[ i ] = 376; break;
}
#endif
}
FileClose(hFile);
*/
return(TRUE);
}
void LoadAllItemNames( void )
{
UINT16 usLoop;
for (usLoop = 0; usLoop < MAXITEMS; usLoop++)
{
LoadItemInfo( usLoop, ItemNames[usLoop], NULL );
// Load short item info
LoadShortNameItemInfo( usLoop, ShortItemNames[usLoop] );
}
}
void LoadAllExternalText( void )
{
LoadAllItemNames();
}
INT16* GetWeightUnitString( void )
{
if ( gGameSettings.fOptions[ TOPTION_USE_METRIC_SYSTEM ] ) // metric
{
return(INT16 *)( pMessageStrings[ MSG_KILOGRAM_ABBREVIATION ] );
}
else
{
return(INT16 *)( pMessageStrings[ MSG_POUND_ABBREVIATION ] );
}
}
FLOAT GetWeightBasedOnMetricOption( UINT32 uiObjectWeight )
{
FLOAT fWeight = 0.0f;
//if the user is smart and wants things displayed in 'metric'
if ( gGameSettings.fOptions[ TOPTION_USE_METRIC_SYSTEM ] ) // metric
{
fWeight = (FLOAT)uiObjectWeight;
}
//else the user is a caveman and display it in pounds
else
{
fWeight = uiObjectWeight * 2.2f;
}
return( fWeight );
}
+1426
View File
File diff suppressed because it is too large Load Diff
+351
View File
@@ -0,0 +1,351 @@
#ifdef PRECOMPILEDHEADERS
#include "Utils All.h"
#include "interface control.h"
#else
#include <windows.h>
#include <mmsystem.h>
#include <string.h>
#include "wcheck.h"
#include "stdlib.h"
#include "debug.h"
#include "Soldier Control.h"
#include "Timer Control.h"
#include "overhead.h"
#include "handle items.h"
#include "worlddef.h"
#include "renderworld.h"
#endif
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
INT32 giClockTimer = -1;
INT32 giTimerDiag = 0;
UINT32 guiBaseJA2Clock = 0;
UINT32 guiBaseJA2NoPauseClock = 0;
BOOLEAN gfPauseClock = FALSE;
INT32 giTimerIntervals[ NUMTIMERS ] =
{
5, // Tactical Overhead
20, // NEXTSCROLL
200, // Start Scroll
200, // Animate tiles
1000, // FPS Counter
80, // PATH FIND COUNTER
150, // CURSOR TIMER
250, // RIGHT CLICK FOR MENU
300, // LEFT
30, // SLIDING TEXT
200, // TARGET REFINE TIMER
150, // CURSOR/AP FLASH
60, // FADE MERCS OUT
160, // PANEL SLIDE
1000, // CLOCK UPDATE DELAY
20, // PHYSICS UPDATE
100, // FADE ENEMYS
20, // STRATEGIC OVERHEAD
40,
500, // NON GUN TARGET REFINE TIMER
250, // IMPROVED CURSOR FLASH
500, // 2nd CURSOR FLASH
400, // RADARMAP BLINK AND OVERHEAD MAP BLINK SHOUDL BE THE SAME
400,
10, // Music Overhead
100, // Rubber band start delay
};
// TIMER COUNTERS
INT32 giTimerCounters[ NUMTIMERS ];
INT32 giTimerAirRaidQuote = 0;
INT32 giTimerAirRaidDiveStarted = 0;
INT32 giTimerAirRaidUpdate = 0;
INT32 giTimerCustomizable = 0;
INT32 giTimerTeamTurnUpdate = 0;
CUSTOMIZABLE_TIMER_CALLBACK gpCustomizableTimerCallback = NULL;
// Clock Callback event ID
MMRESULT gTimerID;
// GLOBALS FOR CALLBACK
UINT32 gCNT;
SOLDIERTYPE *gPSOLDIER;
// GLobal for displaying time diff ( DIAG )
UINT32 guiClockDiff = 0;
UINT32 guiClockStart = 0;
extern UINT32 guiCompressionStringBaseTime;
extern INT32 giFlashHighlightedItemBaseTime;
extern INT32 giCompatibleItemBaseTime;
extern INT32 giAnimateRouteBaseTime;
extern INT32 giPotHeliPathBaseTime;
extern INT32 giClickHeliIconBaseTime;
extern INT32 giExitToTactBaseTime;
extern UINT32 guiSectorLocatorBaseTime;
extern INT32 giCommonGlowBaseTime;
extern INT32 giFlashAssignBaseTime;
extern INT32 giFlashContractBaseTime;
extern UINT32 guiFlashCursorBaseTime;
extern INT32 giPotCharPathBaseTime;
UINT32 InitializeJA2TimerCallback( UINT32 uiDelay, LPTIMECALLBACK TimerProc, UINT32 uiUser );
// CALLBACKS
void CALLBACK FlashItem( UINT uiID, UINT uiMsg, DWORD uiUser, DWORD uiDw1, DWORD uiDw2 );
void CALLBACK TimeProc( UINT uID, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2 )
{
static BOOLEAN fInFunction = FALSE;
//SOLDIERTYPE *pSoldier;
if ( !fInFunction )
{
fInFunction = TRUE;
guiBaseJA2NoPauseClock += BASETIMESLICE;
if ( !gfPauseClock )
{
guiBaseJA2Clock += BASETIMESLICE;
for ( gCNT = 0; gCNT < NUMTIMERS; gCNT++ )
{
UPDATECOUNTER( gCNT );
}
// Update some specialized countdown timers...
UPDATETIMECOUNTER( giTimerAirRaidQuote );
UPDATETIMECOUNTER( giTimerAirRaidDiveStarted );
UPDATETIMECOUNTER( giTimerAirRaidUpdate );
UPDATETIMECOUNTER( giTimerTeamTurnUpdate );
if ( gpCustomizableTimerCallback )
{
UPDATETIMECOUNTER( giTimerCustomizable );
}
#ifndef BOUNDS_CHECKER
// If mapscreen...
if( guiTacticalInterfaceFlags & INTERFACE_MAPSCREEN )
{
// IN Mapscreen, loop through player's team.....
for ( gCNT = gTacticalStatus.Team[ gbPlayerNum ].bFirstID; gCNT <= gTacticalStatus.Team[ gbPlayerNum ].bLastID; gCNT++ )
{
gPSOLDIER = MercPtrs[ gCNT ];
UPDATETIMECOUNTER( gPSOLDIER->PortraitFlashCounter );
UPDATETIMECOUNTER( gPSOLDIER->PanelAnimateCounter );
}
}
else
{
// Set update flags for soldiers
////////////////////////////
for ( gCNT = 0; gCNT < guiNumMercSlots; gCNT++ )
{
gPSOLDIER = MercSlots[ gCNT ];
if ( gPSOLDIER != NULL )
{
UPDATETIMECOUNTER( gPSOLDIER->UpdateCounter );
UPDATETIMECOUNTER( gPSOLDIER->DamageCounter );
UPDATETIMECOUNTER( gPSOLDIER->ReloadCounter );
UPDATETIMECOUNTER( gPSOLDIER->FlashSelCounter );
UPDATETIMECOUNTER( gPSOLDIER->BlinkSelCounter );
UPDATETIMECOUNTER( gPSOLDIER->PortraitFlashCounter );
UPDATETIMECOUNTER( gPSOLDIER->AICounter );
UPDATETIMECOUNTER( gPSOLDIER->FadeCounter );
UPDATETIMECOUNTER( gPSOLDIER->NextTileCounter );
UPDATETIMECOUNTER( gPSOLDIER->PanelAnimateCounter );
}
}
}
#endif
}
fInFunction = FALSE;
}
}
BOOLEAN InitializeJA2Clock(void)
{
#ifdef CALLBACKTIMER
MMRESULT mmResult;
TIMECAPS tc;
INT32 cnt;
// Init timer delays
for ( cnt = 0; cnt < NUMTIMERS; cnt++ )
{
giTimerCounters[ cnt ] = giTimerIntervals[ cnt ];
}
// First get timer resolutions
mmResult = timeGetDevCaps( &tc, sizeof( tc ) );
if ( mmResult != TIMERR_NOERROR )
{
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "Could not get timer properties");
}
// Set timer at lowest resolution. Could use middle of lowest/highest, we'll see how this performs first
gTimerID = timeSetEvent( BASETIMESLICE, BASETIMESLICE, TimeProc, (DWORD)0, TIME_PERIODIC );
if ( !gTimerID )
{
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "Could not create timer callback");
}
#endif
return TRUE;
}
void ShutdownJA2Clock(void)
{
// Make sure we kill the timer
#ifdef CALLBACKTIMER
timeKillEvent( gTimerID );
#endif
}
UINT32 InitializeJA2TimerCallback( UINT32 uiDelay, LPTIMECALLBACK TimerProc, UINT32 uiUser )
{
MMRESULT mmResult;
TIMECAPS tc;
MMRESULT TimerID;
// First get timer resolutions
mmResult = timeGetDevCaps( &tc, sizeof( tc ) );
if ( mmResult != TIMERR_NOERROR )
{
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "Could not get timer properties");
}
// Set timer at lowest resolution. Could use middle of lowest/highest, we'll see how this performs first
TimerID = timeSetEvent( (UINT)uiDelay, (UINT)uiDelay, TimerProc, (DWORD)uiUser, TIME_PERIODIC );
if ( !TimerID )
{
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "Could not create timer callback");
}
return ( (UINT32)TimerID );
}
void RemoveJA2TimerCallback( UINT32 uiTimer )
{
timeKillEvent( uiTimer );
}
UINT32 InitializeJA2TimerID( UINT32 uiDelay, UINT32 uiCallbackID, UINT32 uiUser )
{
switch( uiCallbackID )
{
case ITEM_LOCATOR_CALLBACK:
return( InitializeJA2TimerCallback( uiDelay, FlashItem, uiUser ) );
break;
}
// invalid callback id
Assert( FALSE );
return( 0 );
}
//////////////////////////////////////////////////////////////////////////////////////////////
// TIMER CALLBACK S
//////////////////////////////////////////////////////////////////////////////////////////////
void CALLBACK FlashItem( UINT uiID, UINT uiMsg, DWORD uiUser, DWORD uiDw1, DWORD uiDw2 )
{
}
void PauseTime( BOOLEAN fPaused )
{
gfPauseClock = fPaused;
}
void SetCustomizableTimerCallbackAndDelay( INT32 iDelay, CUSTOMIZABLE_TIMER_CALLBACK pCallback, BOOLEAN fReplace )
{
if ( gpCustomizableTimerCallback )
{
if ( !fReplace )
{
// replace callback but call the current callback first
gpCustomizableTimerCallback();
}
}
RESETTIMECOUNTER( giTimerCustomizable, iDelay );
gpCustomizableTimerCallback = pCallback;
}
void CheckCustomizableTimer( void )
{
if ( gpCustomizableTimerCallback )
{
if ( TIMECOUNTERDONE( giTimerCustomizable, 0 ) )
{
// set the callback to a temp variable so we can reset the global variable
// before calling the callback, so that if the callback sets up another
// instance of the timer, we don't reset it afterwards
CUSTOMIZABLE_TIMER_CALLBACK pTempCallback;
pTempCallback = gpCustomizableTimerCallback;
gpCustomizableTimerCallback = NULL;
pTempCallback();
}
}
}
void ResetJA2ClockGlobalTimers( void )
{
UINT32 uiCurrentTime = GetJA2Clock();
guiCompressionStringBaseTime = uiCurrentTime;
giFlashHighlightedItemBaseTime = uiCurrentTime;
giCompatibleItemBaseTime = uiCurrentTime;
giAnimateRouteBaseTime = uiCurrentTime;
giPotHeliPathBaseTime = uiCurrentTime;
giClickHeliIconBaseTime = uiCurrentTime;
giExitToTactBaseTime = uiCurrentTime;
guiSectorLocatorBaseTime = uiCurrentTime;
giCommonGlowBaseTime = uiCurrentTime;
giFlashAssignBaseTime = uiCurrentTime;
giFlashContractBaseTime = uiCurrentTime;
guiFlashCursorBaseTime = uiCurrentTime;
giPotCharPathBaseTime = uiCurrentTime;
}
+124
View File
@@ -0,0 +1,124 @@
#ifndef __TIMER_CONTROL_H
#define __TIMER_CONTROL_H
#ifndef CALLBACKTIMER
#define CALLBACKTIMER
#endif
typedef INT32 TIMECOUNTER;
//typedef void (__stdcall *JA2_TIMERPROC)( UINT32 uiID, UINT32 uiMsg, UINT32 uiUser, UINT32 uiDw1, UINT32 uiDw2 );
typedef void (*CUSTOMIZABLE_TIMER_CALLBACK) ( void );
// CALLBACK TIMER DEFINES
enum
{
ITEM_LOCATOR_CALLBACK,
NUM_TIMER_CALLBACKS
};
// TIMER DEFINES
enum
{
TOVERHEAD = 0, // Overhead time slice
NEXTSCROLL, // Scroll Speed timer
STARTSCROLL, // Scroll Start timer
ANIMATETILES, // Animate tiles timer
FPSCOUNTER, // FPS value
PATHFINDCOUNTER, // PATH FIND COUNTER
CURSORCOUNTER, // ANIMATED CURSOR
RMOUSECLICK_DELAY_COUNTER, // RIGHT BUTTON CLICK DELAY
LMOUSECLICK_DELAY_COUNTER, // LEFT BUTTON CLICK DELAY
SLIDETEXT, // DAMAGE DISPLAY
TARGETREFINE, // TARGET REFINE
CURSORFLASH, // Cursor/AP flash
FADE_GUY_OUT, // FADE MERCS OUT
PANELSLIDE_UNUSED, // PANLE SLIDE
TCLOCKUPDATE, // CLOCK UPDATE
PHYSICSUPDATE, // PHYSICS UPDATE.
GLOW_ENEMYS,
STRATEGIC_OVERHEAD, // STRATEGIC OVERHEAD
CYCLERENDERITEMCOLOR, // CYCLE COLORS
NONGUNTARGETREFINE, // TARGET REFINE
CURSORFLASHUPDATE, //
INVALID_AP_HOLD, // TIME TO HOLD INVALID AP
RADAR_MAP_BLINK, // BLINK DELAY FOR RADAR MAP
OVERHEAD_MAP_BLINK, // OVERHEADMAP
MUSICOVERHEAD, // MUSIC TIMER
RUBBER_BAND_START_DELAY,
NUMTIMERS
};
// Base resultion of callback timer
#define BASETIMESLICE 10
// TIMER INTERVALS
extern INT32 giTimerIntervals[ NUMTIMERS ];
// TIMER COUNTERS
extern INT32 giTimerCounters[ NUMTIMERS ];
// GLOBAL SYNC TEMP TIME
extern INT32 giClockTimer;
extern INT32 giTimerDiag;
extern INT32 giTimerTeamTurnUpdate;
// Functions
BOOLEAN InitializeJA2Clock( void );
void ShutdownJA2Clock( void );
#define GetJA2Clock() guiBaseJA2Clock
UINT32 GetPauseJA2Clock( );
UINT32 InitializeJA2TimerID( UINT32 uiDelay, UINT32 uiCallbackID, UINT32 uiUser );
void RemoveJA2TimerCallback( UINT32 uiTimer );
void PauseTime( BOOLEAN fPaused );
void SetCustomizableTimerCallbackAndDelay( INT32 iDelay, CUSTOMIZABLE_TIMER_CALLBACK pCallback, BOOLEAN fReplace );
void CheckCustomizableTimer( void );
//Don't modify this value
extern UINT32 guiBaseJA2Clock;
extern CUSTOMIZABLE_TIMER_CALLBACK gpCustomizableTimerCallback;
// MACROS
// CHeck if new counter < 0 | set to 0 | Decrement
#ifdef CALLBACKTIMER
#define UPDATECOUNTER( c ) ( ( giTimerCounters[ c ] - BASETIMESLICE ) < 0 ) ? ( giTimerCounters[ c ] = 0 ) : ( giTimerCounters[ c ] -= BASETIMESLICE )
#define RESETCOUNTER( c ) ( giTimerCounters[ c ] = giTimerIntervals[ c ] )
#define COUNTERDONE( c ) ( giTimerCounters[ c ] == 0 ) ? TRUE : FALSE
#define UPDATETIMECOUNTER( c ) ( ( c - BASETIMESLICE ) < 0 ) ? ( c = 0 ) : ( c -= BASETIMESLICE )
#define RESETTIMECOUNTER( c, d ) ( c = d )
#ifdef BOUNDS_CHECKER
#define TIMECOUNTERDONE( c, d ) ( TRUE )
#else
#define TIMECOUNTERDONE( c, d ) ( c == 0 ) ? TRUE : FALSE
#endif
#define SYNCTIMECOUNTER( )
#define ZEROTIMECOUNTER( c ) ( c = 0 )
#else
#define UPDATECOUNTER( c )
#define RESETCOUNTER( c ) ( giTimerCounters[ c ] = giClockTimer )
#define COUNTERDONE( c ) ( ( ( giClockTimer = GetJA2Clock() ) - giTimerCounters[ c ] ) > giTimerIntervals[ c ] ) ? TRUE : FALSE
#define UPDATETIMECOUNTER( c )
#define RESETTIMECOUNTER( c, d ) ( c = giClockTimer )
#define TIMECOUNTERDONE( c, d ) ( giClockTimer - c > d ) ? TRUE : FALSE
#define SYNCTIMECOUNTER( ) ( giClockTimer = GetJA2Clock() )
#endif
#endif
+481
View File
@@ -0,0 +1,481 @@
#ifdef PRECOMPILEDHEADERS
#include "Utils All.h"
#else
#include "types.h"
#include <stdio.h>
#include <Windows.h>
#include "sgp.h"
#include "time.h"
#include "vobject.h"
#include "FileMan.h"
#include "Utilities.h"
#include "Font Control.h"
#include "overhead.h"
#include "overhead types.h"
#include "wcheck.h"
#include "sys globals.h"
#endif
extern BOOLEAN GetCDromDriveLetter( STR8 pString );
#define DATA_8_BIT_DIR "8-Bit\\"
BOOLEAN PerformTimeLimitedCheck();
//#define TIME_LIMITED_VERSION
void FilenameForBPP(STR pFilename, STR pDestination)
{
UINT8 Drive[128], Dir[128], Name[128], Ext[128];
if(GETPIXELDEPTH()==16)
{
// no processing for 16 bit names
strcpy(pDestination, pFilename);
}
else
{
_splitpath(pFilename, (char *)Drive, (char *)Dir, (char *)Name, (char *)Ext);
strcat(Name, "_8");
strcpy(pDestination, Drive);
//strcat(pDestination, Dir);
strcat(pDestination, DATA_8_BIT_DIR);
strcat(pDestination, Name);
strcat(pDestination, Ext);
}
}
BOOLEAN CreateSGPPaletteFromCOLFile( SGPPaletteEntry *pPalette, SGPFILENAME ColFile )
{
HWFILE hFileHandle;
BYTE bColHeader[ 8 ];
UINT32 cnt;
//See if files exists, if not, return error
if ( !FileExists( ColFile ) )
{
// Return FALSE w/ debug
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "Cannot find COL file");
return( FALSE );
}
// Open and read in the file
if ( ( hFileHandle = FileOpen( ColFile, FILE_ACCESS_READ, FALSE)) == 0)
{
// Return FALSE w/ debug
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "Cannot open COL file");
return( FALSE );
}
// Skip header
FileRead( hFileHandle, bColHeader, sizeof( bColHeader ) , NULL);
// Read in a palette entry at a time
for ( cnt = 0; cnt < 256; cnt++ )
{
FileRead( hFileHandle, &pPalette[ cnt ].peRed, sizeof( UINT8 ) , NULL);
FileRead( hFileHandle, &pPalette[ cnt ].peGreen, sizeof( UINT8 ) , NULL);
FileRead( hFileHandle, &pPalette[ cnt ].peBlue, sizeof( UINT8 ) , NULL);
}
// Close file
FileClose( hFileHandle );
return( TRUE );
}
BOOLEAN DisplayPaletteRep( PaletteRepID aPalRep, UINT8 ubXPos, UINT8 ubYPos, UINT32 uiDestSurface )
{
UINT16 us16BPPColor;
UINT32 cnt1;
UINT8 ubSize, ubType;
INT16 sTLX, sTLY, sBRX, sBRY;
UINT8 ubPaletteRep;
// Create 16BPP Palette
CHECKF( GetPaletteRepIndexFromID( aPalRep, &ubPaletteRep ) );
SetFont( LARGEFONT1 );
ubType = gpPalRep[ ubPaletteRep ].ubType;
ubSize = gpPalRep[ ubPaletteRep ].ubPaletteSize;
for ( cnt1 = 0; cnt1 < ubSize; cnt1++ )
{
sTLX = ubXPos + (UINT16)( ( cnt1 % 16 ) * 20 );
sTLY = ubYPos + (UINT16)( ( cnt1 / 16 ) * 20 );
sBRX = sTLX + 20;
sBRY = sTLY + 20;
us16BPPColor = Get16BPPColor( FROMRGB( gpPalRep[ ubPaletteRep ].r[ cnt1 ], gpPalRep[ ubPaletteRep ].g[ cnt1 ], gpPalRep[ ubPaletteRep ].b[ cnt1 ] ) );
ColorFillVideoSurfaceArea( uiDestSurface, sTLX, sTLY, sBRX, sBRY, us16BPPColor );
}
gprintf( ubXPos + ( 16 * 20 ), ubYPos, L"%S", gpPalRep[ ubPaletteRep ].ID );
return( TRUE );
}
BOOLEAN WrapString( INT16 *pStr, INT16 *pStr2, UINT16 usWidth, INT32 uiFont )
{
UINT32 Cur, uiLet, uiNewLet, uiHyphenLet;
UINT16 *curletter,transletter;
BOOLEAN fLineSplit = FALSE;
HVOBJECT hFont;
// CHECK FOR WRAP
Cur=0;
uiLet = 0;
curletter = (UINT16 *)pStr;
// GET FONT
hFont = GetFontObject( uiFont );
// LOOP FORWARDS AND COUNT
while((*curletter)!=0)
{
transletter=GetIndex(*curletter);
Cur+=GetWidth( hFont, transletter );
if ( Cur > usWidth )
{
// We are here, loop backwards to find a space
// Generate second string, and exit upon completion.
uiHyphenLet = uiLet; //Save the hyphen location as it won't change.
uiNewLet = uiLet;
while((*curletter)!=0)
{
if ( (*curletter) == 32 )
{
// Split Line!
fLineSplit = TRUE;
pStr[ uiNewLet ] = (INT16)'\0';
wcscpy( pStr2, &(pStr[ uiNewLet + 1 ]) );
}
if ( fLineSplit )
break;
uiNewLet--;
curletter--;
}
if( !fLineSplit)
{
//We completed the check for a space, but failed, so use the hyphen method.
swprintf( (wchar_t *)pStr2, (wchar_t *)L"-%s", &(pStr[uiHyphenLet]) );
pStr[uiHyphenLet] = (INT16)'/0';
fLineSplit = TRUE; //hyphen method
break;
}
}
// if ( fLineSplit )
// break;
uiLet++;
curletter++;
}
return( fLineSplit );
}
BOOLEAN IfWinNT(void)
{
OSVERSIONINFO OsVerInfo;
OsVerInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&OsVerInfo);
if ( OsVerInfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
return(TRUE);
else
return(FALSE);
}
BOOLEAN IfWin95(void)
{
OSVERSIONINFO OsVerInfo;
OsVerInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&OsVerInfo);
if ( OsVerInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
return(TRUE);
else
return(FALSE);
}
void HandleLimitedNumExecutions( )
{
// Get system directory
HWFILE hFileHandle;
UINT8 ubSysDir[ 512 ];
INT8 bNumRuns;
GetSystemDirectory( (LPSTR) ubSysDir, sizeof( ubSysDir ) );
// Append filename
strcat( ubSysDir, "\\winaese.dll" );
// Open file and check # runs...
if ( FileExists( (STR)ubSysDir ) )
{
// Open and read
if ( ( hFileHandle = FileOpen( (STR)ubSysDir, FILE_ACCESS_READ, FALSE)) == 0)
{
return;
}
// Read value
FileRead( hFileHandle, &bNumRuns, sizeof( bNumRuns ) , NULL);
// Close file
FileClose( hFileHandle );
if ( bNumRuns <= 0 )
{
// Fail!
SET_ERROR( "Error 1054: Cannot execute - contact Sir-Tech Software." );
return;
}
}
else
{
bNumRuns = 10;
}
// OK, decrement # runs...
bNumRuns--;
// Open and write
if ( ( hFileHandle = FileOpen( (STR)ubSysDir, FILE_ACCESS_WRITE, FALSE)) == 0)
{
return;
}
// Write value
FileWrite( hFileHandle, &bNumRuns, sizeof( bNumRuns ) , NULL);
// Close file
FileClose( hFileHandle );
}
SGPFILENAME gCheckFilenames[] =
{
"DATA\\INTRO.SLF",
"DATA\\LOADSCREENS.SLF",
"DATA\\MAPS.SLF",
"DATA\\NPC_SPEECH.SLF",
"DATA\\SPEECH.SLF",
};
UINT32 gCheckFileMinSizes[] =
{
68000000,
36000000,
87000000,
187000000,
236000000
};
#if defined( JA2TESTVERSION ) || defined( _DEBUG )
#define NOCDCHECK
#endif
#if defined( RUSSIANGOLD )
// CD check enabled
#else
#define NOCDCHECK
#endif
BOOLEAN HandleJA2CDCheck( )
{
#ifdef TIME_LIMITED_VERSION
if( !PerformTimeLimitedCheck() )
{
return( FALSE );
}
#endif
#ifdef NOCDCHECK
return( TRUE );
#else
BOOLEAN fFailed = FALSE;
CHAR8 zCdLocation[ SGPFILENAME_LEN ];
CHAR8 zCdFile[ SGPFILENAME_LEN ];
INT32 cnt;
HWFILE hFile;
// Check for a file on CD....
if( GetCDromDriveLetter( zCdLocation ) )
{
for ( cnt = 0; cnt < 5; cnt++ )
{
// OK, build filename
sprintf( zCdFile, "%s%s", zCdLocation, gCheckFilenames[ cnt ] );
hFile = FileOpen( zCdFile, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE );
// Check if it exists...
if ( !hFile )
{
fFailed = TRUE;
FileClose( hFile );
break;
}
// Check min size
//#ifndef GERMAN
// if ( FileGetSize( hFile ) < gCheckFileMinSizes[ cnt ] )
// {
// fFailed = TRUE;
// FileClose( hFile );
// break;
// }
//#endif
FileClose( hFile );
}
}
else
{
fFailed = TRUE;
}
if ( fFailed )
{
CHAR8 zErrorMessage[256];
sprintf( zErrorMessage, "%S", gzLateLocalizedString[ 56 ] );
// Pop up message boc and get answer....
if ( MessageBox( NULL, zErrorMessage, "Jagged Alliance 2", MB_OK ) == IDOK )
{
return( FALSE );
}
}
return( TRUE );
#endif
}
BOOLEAN HandleJA2CDCheckTwo( )
{
#ifdef NOCDCHECK
return( TRUE );
#else
BOOLEAN fFailed = TRUE;
CHAR8 zCdLocation[ SGPFILENAME_LEN ];
CHAR8 zCdFile[ SGPFILENAME_LEN ];
// Check for a file on CD....
if( GetCDromDriveLetter( zCdLocation ) )
{
// OK, build filename
sprintf( zCdFile, "%s%s", zCdLocation, gCheckFilenames[ Random( 2 ) ] );
// Check if it exists...
if ( FileExists( zCdFile ) )
{
fFailed = FALSE;
}
}
if ( fFailed )
{
CHAR8 zErrorMessage[256];
sprintf( zErrorMessage, "%S", gzLateLocalizedString[ 56 ] );
// Pop up message boc and get answer....
if ( MessageBox( NULL, zErrorMessage, "Jagged Alliance 2", MB_OK ) == IDOK )
{
return( FALSE );
}
}
else
{
return( TRUE );
}
#endif
return( FALSE );
}
BOOLEAN PerformTimeLimitedCheck()
{
#ifndef TIME_LIMITED_VERSION
return( TRUE );
#else
SYSTEMTIME sSystemTime;
GetSystemTime( &sSystemTime );
//if according to the system clock, we are past july 1999, quit the game
if( sSystemTime.wYear > 1999 || sSystemTime.wMonth > 7 )
{
//spit out an error message
MessageBox( NULL, "This time limited version of Jagged Alliance 2 has expired.", "Ja2 Error!", MB_OK );
return( FALSE );
}
return( TRUE );
#endif
}
BOOLEAN DoJA2FilesExistsOnDrive( CHAR8 *zCdLocation )
{
BOOLEAN fFailed = FALSE;
CHAR8 zCdFile[ SGPFILENAME_LEN ];
INT32 cnt;
HWFILE hFile;
for ( cnt = 0; cnt < 4; cnt++ )
{
// OK, build filename
sprintf( zCdFile, "%s%s", zCdLocation, gCheckFilenames[ cnt ] );
hFile = FileOpen( zCdFile, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE );
// Check if it exists...
if ( !hFile )
{
fFailed = TRUE;
FileClose( hFile );
break;
}
FileClose( hFile );
}
return( !fFailed );
}
+33
View File
@@ -0,0 +1,33 @@
#ifndef _UTILITIES_H_
#define _UTILITIES_H_
#include "Overhead types.h"
#include "sgp.h"
#define GETPIXELDEPTH( ) ( gbPixelDepth )
BOOLEAN CreateSGPPaletteFromCOLFile( SGPPaletteEntry *pPalette, SGPFILENAME ColFile );
BOOLEAN DisplayPaletteRep( PaletteRepID aPalRep, UINT8 ubXPos, UINT8 ubYPos, UINT32 uiDestSurface );
void FilenameForBPP(STR pFilename, STR pDestination);
BOOLEAN WrapString( INT16 *pStr, INT16 *pStr2, UINT16 usWidth, INT32 uiFont );
BOOLEAN IfWinNT(void);
BOOLEAN IfWin95(void);
void HandleLimitedNumExecutions( );
BOOLEAN HandleJA2CDCheck( );
BOOLEAN HandleJA2CDCheckTwo( );
// Snap: integer division that rounds the result to the nearest integer
template<class Integer>
inline Integer idiv(Integer a, Integer b)
{
return a > 0 ? b > 0 ? (a + b/2) / b : (a - b/2) / b :
b > 0 ? (a - b/2) / b : (a + b/2) / b ;
}
#endif
+110
View File
@@ -0,0 +1,110 @@
#ifndef __UTILS_ALL_H
#define __UTILS_ALL_H
#pragma message("GENERATED PCH FOR UTILS PROJECT.")
#include "types.h"
#include "Animated ProgressBar.h"
#include "MemMan.h"
#include "debug.h"
#include "Font Control.h"
#include "vsurface.h"
#include "video.h"
#include "Render Dirty.h"
#include "music control.h"
#include <wchar.h>
#include "sgp.h"
#include "cursors.h"
#include "Timer Control.h"
#include "jascreens.h"
#include "font.h"
#include "Sys Globals.h"
#include "Handle UI.h"
#include "interface.h"
#include "overhead.h"
#include "Cursor Control.h"
#include "Debug Control.h"
#include "stdio.h"
#include "Encrypted File.h"
#include "FileMan.h"
#include <stdio.h>
#include <stdarg.h>
#include <time.h>
#include "container.h"
#include "wcheck.h"
#include "Event Manager.h"
#include "Event Pump.h"
#include "Timer.h"
#include "Soldier Control.h"
#include "Sound Control.h"
#include "weapons.h"
#include "Animation Control.h"
#include "opplist.h"
#include "himage.h"
#include "vsurface_private.h"
#include "Language Defines.h"
#include "text.h"
#include "Screens.h"
#include "Maputility.h"
#include "worlddef.h"
#include "loadscreen.h"
#include "overhead map.h"
#include "radar screen.h"
#include "vobject_blitters.h"
#include "sticonvert.h"
#include "worlddat.h"
#include "english.h"
#include "map information.h"
#include "line.h"
#include "MercTextBox.h"
#include "renderworld.h"
#include "Utilities.h"
#include "WordWrap.h"
#include "Message.h"
#include <memory.h>
#include "mbstring.h"
#include "Mutex Manager.h"
#include "local.h"
#include "Map Screen Interface Bottom.h"
#include "Soundman.h"
#include "BuildDefines.h"
#include "Dialogue Control.h"
#include "Multi Language Graphic Utils.h"
#include "Random.h"
#include "gamescreen.h"
#include "Creature Spreading.h"
#include "strategicmap.h"
#include "fade screen.h"
#include "PopUpBox.h"
#include "sysutil.h"
#include "phys math.h"
#include "Types.h"
#include "WordWrap.h"
#include "Render Dirty.h"
#include "Utilities.h"
#include "Cursors.h"
#include "WCheck.h"
#include "Slider.h"
#include "SysUtil.h"
#include "Line.h"
#include "isometric utils.h"
#include <stdlib.h>
#include <string.h>
#include "compression.h"
#include "imgfmt.h"
#include "pcx.h"
#include "impTGA.h"
#include <math.h>
#include "input.h"
#include "Text Input.h"
#include "GameSettings.h"
#include "handle items.h"
#include "time.h"
#include "vobject.h"
#include "overhead types.h"
#include "tactical save.h"
//#include <windows.h>
//#include <windowsx.h>
//#include <mmsystem.h>
//#include <dsound.h>
#endif
+3573
View File
File diff suppressed because it is too large Load Diff
+478
View File
@@ -0,0 +1,478 @@
# 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) Static Library" 0x0104
CFG=Utils - Win32 Demo Bounds Checker
!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 Demo Bounds Checker"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "Utils - Win32 Release" (based on "Win32 (x86) Static Library")
!MESSAGE "Utils - Win32 Debug" (based on "Win32 (x86) Static Library")
!MESSAGE "Utils - Win32 Release with Debug Info" (based on "Win32 (x86) Static Library")
!MESSAGE "Utils - Win32 Bounds Checker" (based on "Win32 (x86) Static Library")
!MESSAGE "Utils - Win32 Debug Demo" (based on "Win32 (x86) Static Library")
!MESSAGE "Utils - Win32 Release Demo" (based on "Win32 (x86) Static Library")
!MESSAGE "Utils - Win32 Demo Release with Debug Info" (based on "Win32 (x86) Static Library")
!MESSAGE "Utils - Win32 Demo Bounds Checker" (based on "Win32 (x86) Static Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""$/Jagged Alliance 2/Development/Programming/Jagged Alliance 2/Build", AVAAAAAA"
# PROP Scc_LocalPath "..\..\..\ja2\build"
CPP=cl.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 "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir "."
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\Standard Gaming Platform" /I "..\TileEngine" /I "..\\" /I "..\Tactical" /I "..\tacticalai" /I "..\Editor" /I "..\strategic" /I "..\Laptop" /I ".\\" /D "CALLBACKTIMER" /D "PRECOMPILEDHEADERS" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "JA2" /D "XML_STATIC" /D "CINTERFACE" /FR /YX"Utils All.h" /FD /c
# ADD BASE RSC /l 0x409
# ADD RSC /l 0x409
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!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 "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir "."
# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
# ADD CPP /nologo /MTd /W3 /GX /Z7 /Od /I "..\Standard Gaming Platform" /I "..\TileEngine" /I "..\\" /I "..\Tactical" /I "..\tacticalai" /I "..\Editor" /I "..\strategic" /I "..\Laptop" /I ".\\" /D "CALLBACKTIMER" /D "PRECOMPILEDHEADERS" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "JA2" /D "_VTUNE_PROFILING" /D "XML_STATIC" /D "CINTERFACE" /FR /YX"Utils All.h" /FD /c
# ADD BASE RSC /l 0x409
# ADD RSC /l 0x409
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ELSEIF "$(CFG)" == "Utils - Win32 Release with Debug Info"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release with Debug Info"
# PROP BASE Intermediate_Dir "Release with Debug Info"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release with Debug"
# PROP Intermediate_Dir "Release with Debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /I "\ja2\Build\Communications" /I "\Standard Gaming Platform" /I "\ja2\Build" /I "\ja2\Build\Tactical" /I "\ja2\Build\TileEngine" /I "\ja2\build\strategic" /I "\ja2\build\editor" /D "NDEBUG" /D "CALLBACKTIMER" /D "WIN32" /D "_WINDOWS" /D "JA2" /FR /YX /FD /c
# ADD CPP /nologo /MT /W4 /GX /Zi /O2 /I "..\Standard Gaming Platform" /I "..\\" /I "..\Tactical" /I "..\TileEngine" /I "..\strategic" /I "..\editor" /I ".\\" /D "NDEBUG" /D "RELEASE_WITH_DEBUG_INFO" /D "CALLBACKTIMER" /D "WIN32" /D "_WINDOWS" /D "JA2" /D "PRECOMPILEDHEADERS" /D "_VTUNE_PROFILING" /D "XML_STATIC" /D "CINTERFACE" /Fr /YX"Utils All.h" /FD /c
# ADD BASE RSC /l 0x409
# ADD RSC /l 0x409
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ELSEIF "$(CFG)" == "Utils - Win32 Bounds Checker"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Utils__0"
# PROP BASE Intermediate_Dir "Utils__0"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Bounds Checker"
# PROP Intermediate_Dir "Bounds Checker"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /GX /Z7 /Od /I "\ja2\build\communications" /I "\Standard Gaming Platform" /I "\ja2\Build" /I "\ja2\Build\Tactical" /I "\ja2\Build\TileEngine" /I "\ja2\build\strategic" /I "\ja2\build\editor" /D "_DEBUG" /D "CALLBACKTIMER" /D "WIN32" /D "_WINDOWS" /D "JA2" /FR /YX /FD /c
# ADD CPP /nologo /MTd /W3 /GX /Z7 /Od /I "\ja2\build\communications" /I "\Standard Gaming Platform" /I "\ja2\Build" /I "\ja2\Build\Tactical" /I "\ja2\Build\TileEngine" /I "\ja2\build\strategic" /I "\ja2\build\editor" /D "_DEBUG" /D "BOUNDS_CHECKER" /D "CALLBACKTIMER" /D "WIN32" /D "_WINDOWS" /D "JA2" /D "PRECOMPILEDHEADERS" /D "_VTUNE_PROFILING" /FR /YX"Utils All.h" /FD /c
# ADD BASE RSC /l 0x409
# ADD RSC /l 0x409
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ELSEIF "$(CFG)" == "Utils - Win32 Debug Demo"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Utils___"
# PROP BASE Intermediate_Dir "Utils___"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug Demo"
# PROP Intermediate_Dir "Debug Demo"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /GX /Z7 /Od /I "\ja2\build\communications" /I "\Standard Gaming Platform" /I "\ja2\Build" /I "\ja2\Build\Tactical" /I "\ja2\Build\TileEngine" /I "\ja2\build\strategic" /I "\ja2\build\editor" /D "_DEBUG" /D "CALLBACKTIMER" /D "WIN32" /D "_WINDOWS" /D "JA2" /FR /YX /FD /c
# ADD CPP /nologo /MTd /W3 /GX /Z7 /Od /I "\ja2\build\communications" /I "\Standard Gaming Platform" /I "\ja2\Build" /I "\ja2\Build\Tactical" /I "\ja2\Build\TileEngine" /I "\ja2\build\strategic" /I "\ja2\build\editor" /D "_DEBUG" /D "JA2DEMO" /D "CALLBACKTIMER" /D "WIN32" /D "_WINDOWS" /D "JA2" /D "PRECOMPILEDHEADERS" /FR /YX"Utils All.h" /FD /c
# ADD BASE RSC /l 0x409
# ADD RSC /l 0x409
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ELSEIF "$(CFG)" == "Utils - Win32 Release Demo"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Utils__1"
# PROP BASE Intermediate_Dir "Utils__1"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release Demo"
# PROP Intermediate_Dir "Release Demo"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W4 /GX /Zi /O2 /I "\ja2\Build\Communications" /I "\Standard Gaming Platform" /I "\ja2\Build" /I "\ja2\Build\Tactical" /I "\ja2\Build\TileEngine" /I "\ja2\build\strategic" /I "\ja2\build\editor" /D "NDEBUG" /D "CALLBACKTIMER" /D "WIN32" /D "_WINDOWS" /D "JA2" /D "RELEASE_WITH_DEBUG_INFO" /Fr /YX /FD /c
# ADD CPP /nologo /MT /W4 /GX /Zi /O2 /I "\ja2\Build\Communications" /I "\Standard Gaming Platform" /I "\ja2\Build" /I "\ja2\Build\Tactical" /I "\ja2\Build\TileEngine" /I "\ja2\build\strategic" /I "\ja2\build\editor" /D "RELEASE_WITH_DEBUG_INFO" /D "NDEBUG" /D "JA2DEMO" /D "CALLBACKTIMER" /D "WIN32" /D "_WINDOWS" /D "JA2" /D "PRECOMPILEDHEADERS" /Fr /YX"Utils All.h" /FD /c
# ADD BASE RSC /l 0x409
# ADD RSC /l 0x409
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ELSEIF "$(CFG)" == "Utils - Win32 Demo Release with Debug Info"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Utils__2"
# PROP BASE Intermediate_Dir "Utils__2"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Demo Release with Debug"
# PROP Intermediate_Dir "Demo Release with Debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W4 /GX /Zi /O2 /I "\ja2\Build\Communications" /I "\Standard Gaming Platform" /I "\ja2\Build" /I "\ja2\Build\Tactical" /I "\ja2\Build\TileEngine" /I "\ja2\build\strategic" /I "\ja2\build\editor" /D "NDEBUG" /D "CALLBACKTIMER" /D "WIN32" /D "_WINDOWS" /D "JA2" /D "RELEASE_WITH_DEBUG_INFO" /Fr /YX /FD /c
# ADD CPP /nologo /MT /W4 /GX /Zi /O2 /I "..\Standard Gaming Platform" /I "..\\" /I "..\Tactical" /I "..\TileEngine" /I "..\strategic" /I "..\editor" /I ".\\" /D "RELEASE_WITH_DEBUG_INFO" /D "NDEBUG" /D "JA2DEMO" /D "CALLBACKTIMER" /D "WIN32" /D "_WINDOWS" /D "JA2" /D "PRECOMPILEDHEADERS" /D "XML_STATIC" /D "CINTERFACE" /Fr /YX"Utils All.h" /FD /c
# ADD BASE RSC /l 0x409
# ADD RSC /l 0x409
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ELSEIF "$(CFG)" == "Utils - Win32 Demo Bounds Checker"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Utils__3"
# PROP BASE Intermediate_Dir "Utils__3"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Demo Bounds Checker"
# PROP Intermediate_Dir "Demo Bounds Checker"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /GX /Z7 /Od /I "\ja2\build\communications" /I "\Standard Gaming Platform" /I "\ja2\Build" /I "\ja2\Build\Tactical" /I "\ja2\Build\TileEngine" /I "\ja2\build\strategic" /I "\ja2\build\editor" /D "CALLBACKTIMER" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "JA2" /D "BOUNDS_CHECKER" /FR /YX /FD /c
# ADD CPP /nologo /MTd /W3 /GX /Z7 /Od /I "\ja2\build\communications" /I "\Standard Gaming Platform" /I "\ja2\Build" /I "\ja2\Build\Tactical" /I "\ja2\Build\TileEngine" /I "\ja2\build\strategic" /I "\ja2\build\editor" /D "_DEBUG" /D "BOUNDS_CHECKER" /D "JA2DEMO" /D "CALLBACKTIMER" /D "WIN32" /D "_WINDOWS" /D "JA2" /D "PRECOMPILEDHEADERS" /FR /YX"Utils All.h" /FD /c
# ADD BASE RSC /l 0x409
# ADD RSC /l 0x409
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ENDIF
# Begin Target
# Name "Utils - Win32 Release"
# Name "Utils - Win32 Debug"
# Name "Utils - Win32 Release with Debug Info"
# Name "Utils - Win32 Bounds Checker"
# Name "Utils - Win32 Debug Demo"
# Name "Utils - Win32 Release Demo"
# Name "Utils - Win32 Demo Release with Debug Info"
# Name "Utils - Win32 Demo Bounds Checker"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
# Begin Source File
SOURCE=.\_DutchText.cpp
# End Source File
# Begin Source File
SOURCE=.\_EnglishText.cpp
# End Source File
# Begin Source File
SOURCE=.\_FrenchText.cpp
# End Source File
# Begin Source File
SOURCE=.\_GermanText.cpp
# End Source File
# Begin Source File
SOURCE=.\_ItalianText.cpp
# End Source File
# Begin Source File
SOURCE=.\_Ja25EnglishText.cpp
# End Source File
# Begin Source File
SOURCE=.\_Ja25GermanText.cpp
# End Source File
# Begin Source File
SOURCE=.\_PolishText.cpp
# End Source File
# Begin Source File
SOURCE=.\_RussianText.cpp
# End Source File
# Begin Source File
SOURCE=".\Animated ProgressBar.cpp"
# End Source File
# Begin Source File
SOURCE=.\Cinematics.cpp
# End Source File
# Begin Source File
SOURCE=.\Cursors.cpp
# End Source File
# Begin Source File
SOURCE=".\Debug Control.cpp"
# End Source File
# Begin Source File
SOURCE=.\dsutil.cpp
# End Source File
# Begin Source File
SOURCE=".\Encrypted File.cpp"
# End Source File
# Begin Source File
SOURCE=".\Event Manager.cpp"
# End Source File
# Begin Source File
SOURCE=".\Event Pump.cpp"
# End Source File
# Begin Source File
SOURCE=".\Font Control.cpp"
# End Source File
# Begin Source File
SOURCE=.\INIReader.cpp
# End Source File
# Begin Source File
SOURCE=.\MapUtility.cpp
# End Source File
# Begin Source File
SOURCE=.\MercTextBox.cpp
# End Source File
# Begin Source File
SOURCE=.\message.cpp
# End Source File
# Begin Source File
SOURCE=".\Multi Language Graphic Utils.cpp"
# End Source File
# Begin Source File
SOURCE=".\Multilingual Text Code Generator.cpp"
# End Source File
# Begin Source File
SOURCE=".\Music Control.cpp"
# End Source File
# Begin Source File
SOURCE=.\PopUpBox.cpp
# End Source File
# Begin Source File
SOURCE=".\Quantize Wrap.cpp"
# End Source File
# Begin Source File
SOURCE=.\Quantize.cpp
# End Source File
# Begin Source File
SOURCE=.\Slider.cpp
# End Source File
# Begin Source File
SOURCE=".\Sound Control.cpp"
# End Source File
# Begin Source File
SOURCE=.\STIConvert.cpp
# End Source File
# Begin Source File
SOURCE=".\Text Input.cpp"
# End Source File
# Begin Source File
SOURCE=".\Text Utils.cpp"
# End Source File
# Begin Source File
SOURCE=".\Timer Control.cpp"
# End Source File
# Begin Source File
SOURCE=.\Utilities.cpp
# End Source File
# Begin Source File
SOURCE=.\WordWrap.cpp
# End Source File
# Begin Source File
SOURCE=.\XML_Items.cpp
# End Source File
# Begin Source File
SOURCE=.\XML_Strings.cpp
# End Source File
# Begin Source File
SOURCE=.\XML_Strings2.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
# Begin Source File
SOURCE=.\_Ja25GermanText.h
# End Source File
# Begin Source File
SOURCE=".\Animated ProgressBar.h"
# End Source File
# Begin Source File
SOURCE=.\cursors.h
# End Source File
# Begin Source File
SOURCE=".\Debug Control.h"
# End Source File
# Begin Source File
SOURCE=.\dsutil.h
# End Source File
# Begin Source File
SOURCE=".\Event Manager.h"
# End Source File
# Begin Source File
SOURCE=".\Event Pump.h"
# End Source File
# Begin Source File
SOURCE=".\Font Control.h"
# End Source File
# Begin Source File
SOURCE=.\INIReader.h
# End Source File
# Begin Source File
SOURCE=.\message.h
# End Source File
# Begin Source File
SOURCE=".\Multi Language Graphic Utils.h"
# End Source File
# Begin Source File
SOURCE=".\Multilingual Text Code Generator.h"
# End Source File
# Begin Source File
SOURCE=".\Music Control.h"
# End Source File
# Begin Source File
SOURCE=".\Sound Control.h"
# End Source File
# Begin Source File
SOURCE=".\Text Input.h"
# End Source File
# Begin Source File
SOURCE=.\Text.h
# End Source File
# Begin Source File
SOURCE=".\Timer Control.h"
# End Source File
# Begin Source File
SOURCE=.\utilities.h
# End Source File
# Begin Source File
SOURCE=".\Utils All.h"
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project
+1684
View File
File diff suppressed because it is too large Load Diff
+3429
View File
File diff suppressed because it is too large Load Diff
+343
View File
@@ -0,0 +1,343 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windowsx.h>
#include <mmsystem.h>
#include <dsound.h>
#include "dsutil.h"
#include "debug.h"
#include "sgp.h"
#include "Sound Control.h"
// THIS MODULE IS TEMPORARY - USED FOR OUR SOUND SYSTEM INTIL IT IS IMPLEMENTED FOR THE SGP
extern HWND ghWindow;
typedef UINT32 EFFECT;
BOOL DSEnable( HWND hwnd );
BOOL DSDisable( void );
BOOL SoundLoadEffect( EFFECT sfx );
BOOL SoundDestroyEffect( EFFECT sfx );
BOOL InitSound( HWND hwndOwner );
BOOL SoundPlayEffect( EFFECT sfx );
void EnableQuickSound( )
{
DSEnable( ghWindow );
InitSound( ghWindow );
}
void DisableQuickSound( )
{
DSDisable( );
}
void PlayQuickSound( INT16 sSound )
{
SoundPlayEffect( (EFFECT)sSound );
}
#define NUM_SOUND_EFFECTS NUM_SAMPLES
LPDIRECTSOUND lpDS = NULL;
LPDIRECTSOUNDBUFFER lpSoundEffects[NUM_SOUND_EFFECTS];
char szSoundEffects[NUM_SOUND_EFFECTS][255] =
{
"SHOOT1",
"MISS1",
"FALL1",
"HIT1",
"HIT2",
"DOOROPEN1",
"DOORCLOSE1",
"BURST1",
"ENDTURN"
};
/*
* DSEnable
*
* Figures out whether or not to use DirectSound, based on an entry
* in WIN.INI. Sets a module-level flag and goes about creating the
* DirectSound object if necessary. Returns TRUE if successful.
*/
BOOL DSEnable( HWND hwnd )
{
HRESULT dsrval;
//BOOL bUseDSound;
if (lpDS != NULL)
{
return TRUE;
}
dsrval = DirectSoundCreate(NULL, &lpDS, NULL);
switch( dsrval )
{
case DSERR_ALLOCATED:
break;
case DSERR_NOAGGREGATION:
break;
case DSERR_OUTOFMEMORY:
break;
case DSERR_INVALIDPARAM:
break;
case DSERR_NODRIVER:
break;
}
if (dsrval != DS_OK)
{
return FALSE;
}
dsrval = IDirectSound_SetCooperativeLevel(lpDS, hwnd, DSSCL_NORMAL);
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "Sound INIT OK");
if (dsrval != DS_OK)
{
DSDisable();
return FALSE;
}
return TRUE;
} /* DSEnable */
/*
* DSDisable
*
* Turn off DirectSound
*/
BOOL DSDisable( void )
{
if (lpDS == NULL)
{
return TRUE;
}
IDirectSound_Release(lpDS);
lpDS = NULL;
return TRUE;
} /* DSDisable */
/*
* InitSound
*
* Sets up the DirectSound object and loads all sounds into secondary
* DirectSound buffers. Returns FALSE on error, or TRUE if successful
*/
BOOL InitSound( HWND hwndOwner )
{
int idx;
DSBUFFERDESC dsBD;
IDirectSoundBuffer *lpPrimary;
DSEnable(hwndOwner);
if (lpDS == NULL)
return TRUE;
/*
* Load all sounds -- any that can't load for some reason will have NULL
* pointers instead of valid SOUNDEFFECT data, and we will know not to
* play them later on.
*/
for( idx = 0; idx < NUM_SOUND_EFFECTS; idx++ )
{
if (SoundLoadEffect((EFFECT)idx))
{
DSBCAPS caps;
caps.dwSize = sizeof(caps);
IDirectSoundBuffer_GetCaps(lpSoundEffects[idx], &caps);
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("_______SOUND(%d) OK", idx));
//if (caps.dwFlags & DSBCAPS_LOCHARDWARE)
//Msg( "Sound effect %s in hardware", szSoundEffects[idx]);
}
else
{
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("_______SOUND(%d) BAD", idx));
//Msg( "cant load sound effect %s", szSoundEffects[idx]);
}
}
/*
* get the primary buffer and start it playing
*
* by playing the primary buffer, DirectSound knows to keep the
* mixer active, even though we are not making any noise.
*/
ZeroMemory( &dsBD, sizeof(DSBUFFERDESC) );
dsBD.dwSize = sizeof(dsBD);
dsBD.dwFlags = DSBCAPS_PRIMARYBUFFER;
if (SUCCEEDED(IDirectSound_CreateSoundBuffer(lpDS, &dsBD, &lpPrimary, NULL)))
{
if (!SUCCEEDED(IDirectSoundBuffer_Play(lpPrimary, 0, 0, DSBPLAY_LOOPING)))
{
//Msg("Unable to play Primary sound buffer");
}
IDirectSoundBuffer_Release(lpPrimary);
}
else
{
//Msg("Unable to create Primary sound buffer");
}
return TRUE;
} /* InitSound */
/*
* DestroySound
*
* Undoes everything that was done in a InitSound call
*/
BOOL DestroySound( void )
{
DWORD idxKill;
for( idxKill = 0; idxKill < NUM_SOUND_EFFECTS; idxKill++ )
{
SoundDestroyEffect( (EFFECT)idxKill );
}
DSDisable();
return TRUE;
} /* DestroySound */
/*
* SoundDestroyEffect
*
* Frees up resources associated with a sound effect
*/
BOOL SoundDestroyEffect( EFFECT sfx )
{
if(lpSoundEffects[sfx])
{
IDirectSoundBuffer_Release(lpSoundEffects[sfx]);
lpSoundEffects[sfx] = NULL;
}
return TRUE;
} /* SoundDestryEffect */
/*
* SoundLoadEffect
*
* Initializes a sound effect by loading the WAV file from a resource
*/
BOOL SoundLoadEffect( EFFECT sfx )
{
if (lpDS && lpSoundEffects[sfx] == NULL && *szSoundEffects[sfx])
{
//
// use DSLoadSoundBuffer (in ..\misc\dsutil.c) to load
// a sound from a resource.
//
lpSoundEffects[sfx] = DSLoadSoundBuffer(lpDS, szSoundEffects[sfx]);
}
return lpSoundEffects[sfx] != NULL;
} /* SoundLoadEffect */
/*
* SoundPlayEffect
*
* Plays the sound effect specified.
* Returns TRUE if succeeded.
*/
BOOL SoundPlayEffect( EFFECT sfx )
{
HRESULT dsrval;
IDirectSoundBuffer *pdsb = lpSoundEffects[sfx];
if( !lpDS || !pdsb )
{
return FALSE;
}
/*
* Rewind the play cursor to the start of the effect, and play
*/
IDirectSoundBuffer_SetCurrentPosition(pdsb, 0);
dsrval = IDirectSoundBuffer_Play(pdsb, 0, 0, 0);
if( dsrval == DS_OK )
if (dsrval == DSERR_BUFFERLOST)
{
//Msg("** %s needs restored", szSoundEffects[sfx]);
dsrval = IDirectSoundBuffer_Restore(pdsb);
if (dsrval == DS_OK)
{
if (DSReloadSoundBuffer(pdsb, szSoundEffects[sfx]))
{
//Msg("** %s has been restored", szSoundEffects[sfx]);
IDirectSoundBuffer_SetCurrentPosition(pdsb, 0);
dsrval = IDirectSoundBuffer_Play(pdsb, 0, 0, 0);
}
else
{
dsrval = E_FAIL;
}
}
}
return (dsrval == DS_OK);
} /* SoundPlayEffect */
/*
* SoundStopEffect
*
* Stops the sound effect specified.
* Returns TRUE if succeeded.
*/
BOOL SoundStopEffect( EFFECT sfx )
{
HRESULT dsrval;
if( !lpDS || !lpSoundEffects[sfx] )
{
return FALSE;
}
dsrval = IDirectSoundBuffer_Stop(lpSoundEffects[sfx]);
return SUCCEEDED(dsrval);
} /* SoundStopEffect */
+12
View File
@@ -0,0 +1,12 @@
#ifndef __WIN_UTIL_H
#define __WIN_UTIL_H
void SetThreadToHighestPriority( );
void EnableQuickSound( );
void DisableQuickSound( );
void PlayQuickSound( INT16 sSound );
#endif
+2032
View File
File diff suppressed because it is too large Load Diff
+76
View File
@@ -0,0 +1,76 @@
#ifndef __WORDWRAP_H_
#define __WORDWRAP_H_
#include "types.h"
#include "LAPTOP\files.h"
#include "LAPTOP\email.h"
//Flags for DrawTextToScreen()
// Defines for coded text For use with IanDisplayWrappedString()
#define TEXT_SPACE 32
#define TEXT_CODE_NEWLINE 177
#define TEXT_CODE_BOLD 178
#define TEXT_CODE_CENTER 179
#define TEXT_CODE_NEWCOLOR 180
#define TEXT_CODE_DEFCOLOR 181
UINT16 IanDisplayWrappedString(UINT16 usPosX, UINT16 usPosY, UINT16 usWidth, UINT8 ubGap, UINT32 uiFont, UINT8 ubColor, STR16 pString, UINT8 ubBackGroundColor, BOOLEAN fDirty, UINT32 uiFlags);
#define LEFT_JUSTIFIED 0x00000001
#define CENTER_JUSTIFIED 0x00000002
#define RIGHT_JUSTIFIED 0x00000004
#define TEXT_SHADOWED 0x00000008
#define INVALIDATE_TEXT 0x00000010
#define DONT_DISPLAY_TEXT 0x00000020 //Wont display the text. Used if you just want to get how many lines will be displayed
#define IAN_WRAP_NO_SHADOW 32
#define NEWLINE_CHAR 177
typedef struct _WRAPPEDSTRING
{
STR16 sString;
struct _WRAPPEDSTRING *pNextWrappedString;
} WRAPPED_STRING;
WRAPPED_STRING * LineWrap(UINT32 ulFont, UINT16 usLineWidthPixels, UINT16 *pusLineWidthIfWordIsWiderThenWidth, STR16 pString, ...);
UINT16 DisplayWrappedString(UINT16 usPosX, UINT16 usPosY, UINT16 usWidth, UINT8 ubGap, UINT32 uiFont, UINT8 ubColor, STR16 pString, UINT8 ubBackGroundColor, BOOLEAN fDirty, UINT32 ulFlags);
UINT16 DeleteWrappedString(WRAPPED_STRING *pWrappedString);
void CleanOutControlCodesFromString(STR16 pSourceString, STR16 pDestString);
INT16 IanDisplayWrappedStringToPages(UINT16 usPosX, UINT16 usPosY, UINT16 usWidth, UINT16 usPageHeight, UINT16 usTotalHeight, UINT16 usPageNumber,UINT8 ubGap,
UINT32 uiFont, UINT8 ubColor, STR16 pString,
UINT8 ubBackGroundColor, BOOLEAN fDirty, UINT32 uiFlags, BOOLEAN *fOnLastPageFlag);
BOOLEAN DrawTextToScreen(STR16 pStr, UINT16 LocX, UINT16 LocY, UINT16 usWidth, UINT32 ulFont, UINT8 ubColor, UINT8 ubBackGroundColor, BOOLEAN fDirty, UINT32 FLAGS);
UINT16 IanWrappedStringHeight(UINT16 usPosX, UINT16 usPosY, UINT16 usWidth, UINT8 ubGap,
UINT32 uiFont, UINT8 ubColor, STR16 pString,
UINT8 ubBackGroundColor, BOOLEAN fDirty, UINT32 uiFlags);
BOOLEAN WillThisStringGetCutOff( INT32 iCurrentYPosition, INT32 iBottomOfPage, INT32 iWrapWidth, UINT32 uiFont, STR16 pString, INT32 iGap, INT32 iPage );
BOOLEAN IsThisStringBeforeTheCurrentPage( INT32 iTotalYPosition, INT32 iPageSize, INT32 iCurrentPage ,INT32 iWrapWidth, UINT32 uiFont, STR16 pString, INT32 iGap );
INT32 GetNewTotalYPositionOfThisString( INT32 iTotalYPosition, INT32 iPageSize, INT32 iCurrentPage ,INT32 iWrapWidth, UINT32 uiFont, STR16 pString, INT32 iGap );
RecordPtr GetFirstRecordOnThisPage( RecordPtr RecordList, UINT32 uiFont, UINT16 usWidth, UINT8 ubGap, INT32 iPage, INT32 iPageSize );
FileStringPtr GetFirstStringOnThisPage( FileStringPtr RecordList, UINT32 uiFont, UINT16 usWidth, UINT8 ubGap, INT32 iPage, INT32 iPageSize, FileRecordWidthPtr iWidthArray );
// Places a shadow the width an height of the string, to PosX, posY
void ShadowText(UINT32 uiDestVSurface, STR16 pString, UINT32 uiFont, UINT16 usPosX, UINT16 usPosY );
BOOLEAN ReduceStringLength( STR16 pString, UINT32 uiWidthToFitIn, UINT32 uiFont );
void UseSingleCharWordsForWordWrap( BOOLEAN fUseSingleCharWords );
WRAPPED_STRING *LineWrapForSingleCharWords(UINT32 ulFont, UINT16 usLineWidthPixels, UINT16 *pusLineWidthIfWordIsWiderThenWidth, STR16 pString, ...);
#endif
+410
View File
@@ -0,0 +1,410 @@
#define WEAPONSFILENAME "TABLEDATA\\Weapons.dat"
#define MAX_CHAR_DATA_LENGTH 500
enum
{
ELEMENT_NONE = 0,
ELEMENT_LIST,
ELEMENT,
ELEMENT_PROPERTY,
}
typedef PARSE_STAGE;
struct
{
PARSE_STAGE curElement;
INT8 szCharData[MAX_CHAR_DATA_LENGTH+1];
WEAPONTYPE curWeapon;
WEAPONTYPE * curWeaponList;
UINT32 maxWeapons;
UINT32 currentDepth;
UINT32 maxReadDepth;
}
typedef ParseData;
static void XMLCALL
StartElementHandle(void *userData, const char *name, const char **atts)
{
ParseData * pData = (ParseData *)userData;
if(pData->currentDepth <= pData->maxReadDepth) //are we reading this element?
{
if(strcmp(name, "LIST") == 0 && pData->curElement == ELEMENT_NONE)
{
pData->curElement = ELEMENTLIST;
memset(pData->curWeaponList,0,sizeof(WEAPONTYPE)*pData->maxWeapons);
pData->maxReadDepth++; //we are not skipping this element
}
else if(strcmp(name, "WEAPON") == 0 && pData->curElement == ELEMENTLIST)
{
pData->curElement = ELEMENT;
memset(&pData->curWeapon,0,sizeof(WEAPONTYPE));
pData->maxReadDepth++; //we are not skipping this element
}
else if(pData->curElement == ELEMENT &&
(strcmp(name, "uiIndex") == 0 ||
strcmp(name, "szWeaponName") == 0 ||
strcmp(name, "ubWeaponClass") == 0 ||
strcmp(name, "ubWeaponType") == 0 ||
strcmp(name, "ubCalibre") == 0 ||
strcmp(name, "ubReadyTime") == 0 ||
strcmp(name, "ubShotsPer4Turns") == 0 ||
strcmp(name, "ubShotsPerBurst") == 0 ||
strcmp(name, "ubBurstPenalty") == 0 ||
strcmp(name, "ubBulletSpeed") == 0 ||
strcmp(name, "ubImpact") == 0 ||
strcmp(name, "ubDeadliness") == 0 ||
strcmp(name, "bAccuracy") == 0 ||
strcmp(name, "ubMagSize") == 0 ||
strcmp(name, "usRange") == 0 ||
strcmp(name, "usReloadDelay") == 0 ||
strcmp(name, "ubAttackVolume") == 0 ||
strcmp(name, "ubHitVolume") == 0 ||
strcmp(name, "sSound") == 0 ||
strcmp(name, "sBurstSound") == 0 ||
strcmp(name, "sReloadSound") == 0 ||
strcmp(name, "sLocknLoadSound") == 0 ||
strcmp(name, "bBaseAutofireCost") == 0 ||
strcmp(name, "bAutofireShotsPerFiveAP") == 0))
{
pData->curElement = ELEMENT_PROPERY;
pData->maxReadDepth++; //we are not skipping this element
}
pData->szCharData[0] = '\0';
}
pData->currentDepth++;
}
static void XMLCALL
weaponCharacterDataHandle(void *userData, const char *str, int len)
{
weaponParseData * pData = (weaponParseData *)userData;
if( (pData->currentDepth <= pData->maxReadDepth) &&
(strlen(pData->szCharData) < MAX_CHAR_DATA_LENGTH)
){
strncat(pData->szCharData,str,__min((unsigned int)len,MAX_CHAR_DATA_LENGTH-strlen(pData->szCharData)));
}
}
static void XMLCALL
weaponEndElementHandle(void *userData, const char *name)
{
weaponParseData * pData = (weaponParseData *)userData;
if(pData->currentDepth <= pData->maxReadDepth) //we're at the end of an element that we've been reading
{
if(strcmp(name, "WEAPONLIST") == 0)
{
pData->curElement = ELEMENT_NONE;
}
else if(strcmp(name, "WEAPON") == 0)
{
pData->curElement = ELEMENTLIST;
if(pData->curWeapon.uiIndex < pData->maxWeapons)
{
pData->curWeaponList[pData->curWeapon.uiIndex] = pData->curWeapon; //write the weapon into the table
}
}
else if(strcmp(name, "uiIndex") == 0)
{
pData->curElement = ELEMENT;
pData->curWeapon.uiIndex = atol(pData->szCharData);
}
else if(strcmp(name, "szWeaponName") == 0)
{
pData->curElement = ELEMENT;
if(MAX_NAME_LENGTH >= strlen(pData->szCharData))
strcpy(pData->curWeapon.szWeaponName,pData->szCharData);
else
{
strncpy(pData->curWeapon.szWeaponName,pData->szCharData,MAX_NAME_LENGTH);
pData->curWeapon.szWeaponName[MAX_NAME_LENGTH] = '\0';
}
}
else if(strcmp(name, "ubWeaponClass") == 0)
{
pData->curElement = ELEMENT;
pData->curWeapon.ubWeaponClass = (UINT8) atol(pData->szCharData);
}
else if(strcmp(name, "ubWeaponType") == 0)
{
pData->curElement = ELEMENT;
pData->curWeapon.ubWeaponType = (UINT8) atol(pData->szCharData);
}
else if(strcmp(name, "ubCalibre") == 0)
{
pData->curElement = ELEMENT;
pData->curWeapon.ubCalibre = (UINT8) atol(pData->szCharData);
}
else if(strcmp(name, "ubReadyTime") == 0)
{
pData->curElement = ELEMENT;
pData->curWeapon.ubReadyTime = (UINT8) atol(pData->szCharData);
}
else if(strcmp(name, "ubShotsPer4Turns") == 0)
{
pData->curElement = ELEMENT;
pData->curWeapon.ubShotsPer4Turns = (UINT8) atol(pData->szCharData);
}
else if(strcmp(name, "ubShotsPerBurst") == 0)
{
pData->curElement = ELEMENT;
pData->curWeapon.ubShotsPerBurst = (UINT8) atol(pData->szCharData);
}
else if(strcmp(name, "ubBurstPenalty") == 0)
{
pData->curElement = ELEMENT;
pData->curWeapon.ubBurstPenalty = (UINT8) atol(pData->szCharData);
}
else if(strcmp(name, "ubBulletSpeed") == 0)
{
pData->curElement = ELEMENT;
pData->curWeapon.ubBulletSpeed = (UINT8) atol(pData->szCharData);
}
else if(strcmp(name, "ubImpact") == 0)
{
pData->curElement = ELEMENT;
pData->curWeapon.ubImpact = (UINT8) atol(pData->szCharData);
}
else if(strcmp(name, "ubDeadliness") == 0)
{
pData->curElement = ELEMENT;
pData->curWeapon.ubDeadliness = (UINT8) atol(pData->szCharData);
}
else if(strcmp(name, "bAccuracy") == 0)
{
pData->curElement = ELEMENT;
pData->curWeapon.bAccuracy = (INT8) atol(pData->szCharData);
}
else if(strcmp(name, "ubMagSize") == 0)
{
pData->curElement = ELEMENT;
pData->curWeapon.ubMagSize = (UINT8) atol(pData->szCharData);
}
else if(strcmp(name, "usRange") == 0)
{
pData->curElement = ELEMENT;
pData->curWeapon.usRange = (UINT16) atol(pData->szCharData);
}
else if(strcmp(name, "usReloadDelay") == 0)
{
pData->curElement = ELEMENT;
pData->curWeapon.usReloadDelay = (UINT16) atol(pData->szCharData);
}
else if(strcmp(name, "ubAttackVolume") == 0)
{
pData->curElement = ELEMENT;
pData->curWeapon.ubAttackVolume = (UINT8) atol(pData->szCharData);
}
else if(strcmp(name, "ubHitVolume") == 0)
{
pData->curElement = ELEMENT;
pData->curWeapon.ubHitVolume = (UINT8) atol(pData->szCharData);
}
else if(strcmp(name, "sSound") == 0)
{
pData->curElement = ELEMENT;
pData->curWeapon.sSound = (UINT16) atol(pData->szCharData);
}
else if(strcmp(name, "sBurstSound") == 0)
{
pData->curElement = ELEMENT;
pData->curWeapon.sBurstSound = (UINT16) atol(pData->szCharData);
}
else if(strcmp(name, "sReloadSound") == 0)
{
pData->curElement = ELEMENT;
pData->curWeapon.sReloadSound = (UINT16) atol(pData->szCharData);
}
else if(strcmp(name, "sLocknLoadSound") == 0)
{
pData->curElement = ELEMENT;
pData->curWeapon.sLocknLoadSound = (UINT16) atol(pData->szCharData);
}
else if(strcmp(name, "bBaseAutofireCost") == 0)
{
pData->curElement = ELEMENT;
pData->curWeapon.bBaseAutofireCost = (UINT8) atol(pData->szCharData);
}
else if(strcmp(name, "bAutofireShotsPerFiveAP") == 0)
{
pData->curElement = ELEMENT;
pData->curWeapon.bAutofireShotsPerFiveAP = (UINT8) atol(pData->szCharData);
}
pData->maxReadDepth--;
}
pData->currentDepth--;
}
BOOLEAN ReadInWeaponStats()
{
HWFILE hFile;
UINT32 uiBytesRead;
UINT32 uiFSize;
CHAR8 * lpcBuffer;
XML_Parser parser = XML_ParserCreate(NULL);
weaponParseData pData;
DebugMsg(TOPIC_JA2, DBG_LEVEL_3, "Loading weapons.dat" );
// Open weapons file
hFile = FileOpen( WEAPONSFILENAME, FILE_ACCESS_READ, FALSE );
if ( !hFile )
return( FALSE );
uiFSize = FileGetSize(hFile);
lpcBuffer = (CHAR8 *) MemAlloc(uiFSize+1);
//Read in block
if ( !FileRead( hFile, lpcBuffer, uiFSize, &uiBytesRead ) )
{
MemFree(lpcBuffer);
return( FALSE );
}
lpcBuffer[uiFSize] = 0; //add a null terminator
FileClose( hFile );
XML_SetElementHandler(parser, weaponStartElementHandle, weaponEndElementHandle);
XML_SetCharacterDataHandler(parser, weaponCharacterDataHandle);
memset(&pData,0,sizeof(pData));
pData.curWeaponList = Weapon;
pData.maxWeapons = MAXITEMS;
XML_SetUserData(parser, &pData);
if(!XML_Parse(parser, lpcBuffer, uiFSize, TRUE))
{
CHAR8 errorBuf[511];
sprintf(errorBuf, "XML Parser Error in Weapons.dat: %s at line %d", XML_ErrorString(XML_GetErrorCode(parser)), XML_GetCurrentLineNumber(parser));
LiveMessage(errorBuf);
MemFree(lpcBuffer);
return FALSE;
}
MemFree(lpcBuffer);
#ifdef JA2TESTVERSION
//Debug code; make sure that what we got from the file is the same as what's there
// Open a new file
hFile = FileOpen( "TABLEDATA\\~Weapons.dat", FILE_ACCESS_WRITE | FILE_CREATE_ALWAYS, FALSE );
if ( !hFile )
return( FALSE );
{
UINT32 cnt;
FilePrintf(hFile,"<WEAPONLIST>\r\n");
for(cnt = 0;cnt < MAXITEMS;cnt++)
{
INT8 * szRemainder = Weapon[cnt].szWeaponName; //the remaining string to be output (for making valid XML)
FilePrintf(hFile,"\t<WEAPON>\r\n");
FilePrintf(hFile,"\t\t<uiIndex>%d</uiIndex>\r\n", Weapon[cnt].uiIndex);
FilePrintf(hFile,"\t\t<szWeaponName>");
while(szRemainder[0] != '\0')
{
UINT32 uiCharLoc = strcspn(szRemainder,"&<>\'\"\0");
INT8 invChar = szRemainder[uiCharLoc];
if(uiCharLoc)
{
szRemainder[uiCharLoc] = '\0';
FilePrintf(hFile,"%s",szRemainder);
szRemainder[uiCharLoc] = invChar;
}
szRemainder += uiCharLoc;
switch(invChar)
{
case '&':
FilePrintf(hFile,"&amp;");
szRemainder++;
break;
case '<':
FilePrintf(hFile,"&lt;");
szRemainder++;
break;
case '>':
FilePrintf(hFile,"&gt;");
szRemainder++;
break;
case '\'':
FilePrintf(hFile,"&apos;");
szRemainder++;
break;
case '\"':
FilePrintf(hFile,"&quot;");
szRemainder++;
break;
}
}
FilePrintf(hFile,"</szWeaponName>\r\n");
FilePrintf(hFile,"\t\t<ubWeaponClass>%d</ubWeaponClass>\r\n", Weapon[cnt].ubWeaponClass);
FilePrintf(hFile,"\t\t<ubWeaponType>%d</ubWeaponType>\r\n", Weapon[cnt].ubWeaponType);
FilePrintf(hFile,"\t\t<ubCalibre>%d</ubCalibre>\r\n", Weapon[cnt].ubCalibre);
FilePrintf(hFile,"\t\t<ubReadyTime>%d</ubReadyTime>\r\n", Weapon[cnt].ubReadyTime);
FilePrintf(hFile,"\t\t<ubShotsPer4Turns>%d</ubShotsPer4Turns>\r\n", Weapon[cnt].ubShotsPer4Turns);
FilePrintf(hFile,"\t\t<ubShotsPerBurst>%d</ubShotsPerBurst>\r\n", Weapon[cnt].ubShotsPerBurst);
FilePrintf(hFile,"\t\t<ubBurstPenalty>%d</ubBurstPenalty>\r\n", Weapon[cnt].ubBurstPenalty);
FilePrintf(hFile,"\t\t<ubBulletSpeed>%d</ubBulletSpeed>\r\n", Weapon[cnt].ubBulletSpeed);
FilePrintf(hFile,"\t\t<ubImpact>%d</ubImpact>\r\n", Weapon[cnt].ubImpact);
FilePrintf(hFile,"\t\t<ubDeadliness>%d</ubDeadliness>\r\n", Weapon[cnt].ubDeadliness);
FilePrintf(hFile,"\t\t<bAccuracy>%d</bAccuracy>\r\n", Weapon[cnt].bAccuracy);
FilePrintf(hFile,"\t\t<ubMagSize>%d</ubMagSize>\r\n", Weapon[cnt].ubMagSize);
FilePrintf(hFile,"\t\t<usRange>%d</usRange>\r\n", Weapon[cnt].usRange);
FilePrintf(hFile,"\t\t<usReloadDelay>%d</usReloadDelay>\r\n", Weapon[cnt].usReloadDelay);
FilePrintf(hFile,"\t\t<ubAttackVolume>%d</ubAttackVolume>\r\n", Weapon[cnt].ubAttackVolume);
FilePrintf(hFile,"\t\t<ubHitVolume>%d</ubHitVolume>\r\n", Weapon[cnt].ubHitVolume);
FilePrintf(hFile,"\t\t<sSound>%d</sSound>\r\n", Weapon[cnt].sSound);
FilePrintf(hFile,"\t\t<sBurstSound>%d</sBurstSound>\r\n", Weapon[cnt].sBurstSound);
FilePrintf(hFile,"\t\t<sReloadSound>%d</sReloadSound>\r\n", Weapon[cnt].sReloadSound);
FilePrintf(hFile,"\t\t<sLocknLoadSound>%d</sLocknLoadSound>\r\n", Weapon[cnt].sLocknLoadSound);
FilePrintf(hFile,"\t\t<bBaseAutofireCost>%d</bBaseAutofireCost>\r\n", Weapon[cnt].bBaseAutofireCost);
FilePrintf(hFile,"\t\t<bAutofireShotsPerFiveAP>%d</bAutofireShotsPerFiveAP>\r\n", Weapon[cnt].bAutofireShotsPerFiveAP);
FilePrintf(hFile,"\t</WEAPON>\r\n");
}
FilePrintf(hFile,"</WEAPONLIST>\r\n");
}
FileClose( hFile );
#endif
XML_ParserFree(parser);
return( TRUE );
}
+1432
View File
File diff suppressed because it is too large Load Diff
+265
View File
@@ -0,0 +1,265 @@
#ifdef PRECOMPILEDHEADERS
#include "Tactical All.h"
#else
#include "sgp.h"
#include "overhead types.h"
#include "Sound Control.h"
#include "Soldier Control.h"
#include "overhead.h"
#include "Event Pump.h"
#include "weapons.h"
#include "Animation Control.h"
#include "sys globals.h"
#include "Handle UI.h"
#include "Isometric Utils.h"
#include "worldman.h"
#include "math.h"
#include "points.h"
#include "ai.h"
#include "los.h"
#include "renderworld.h"
#include "opplist.h"
#include "interface.h"
#include "message.h"
#include "campaign.h"
#include "items.h"
#include "text.h"
#include "Soldier Profile.h"
#include "tile animation.h"
#include "Dialogue Control.h"
#include "SkillCheck.h"
#include "explosion control.h"
#include "Quests.h"
#include "Physics.h"
#include "Random.h"
#include "Vehicles.h"
#include "bullets.h"
#include "morale.h"
#include "meanwhile.h"
#include "SkillCheck.h"
#include "gamesettings.h"
#include "SaveLoadMap.h"
#include "Debug Control.h"
#include "expat.h"
#include "XML.h"
#endif
struct
{
PARSE_STAGE curElement;
INT8 szCharData[MAX_CHAR_DATA_LENGTH+1];
UINT32 maxArraySize;
UINT32 curIndex;
UINT32 currentDepth;
UINT32 maxReadDepth;
}
typedef stringParseData;
static void XMLCALL
stringStartElementHandle(void *userData, const char *name, const char **atts)
{
stringParseData * pData = (stringParseData *)userData;
if(pData->currentDepth <= pData->maxReadDepth) //are we reading this element?
{
if(strcmp(name, "STRINGLIST") == 0 && pData->curElement == ELEMENT_NONE)
{
pData->curElement = ELEMENT_LIST;
pData->maxReadDepth++; //we are not skipping this element
}
else if(strcmp(name, "STRING") == 0 && pData->curElement == ELEMENT_LIST)
{
pData->curElement = ELEMENT_PROPERTY;
pData->maxReadDepth++; //we are not skipping this element
pData->curIndex++;
}
pData->szCharData[0] = '\0';
}
pData->currentDepth++;
}
static void XMLCALL
stringCharacterDataHandle(void *userData, const char *str, int len)
{
stringParseData * pData = (stringParseData *)userData;
if( (pData->currentDepth <= pData->maxReadDepth) &&
(strlen(pData->szCharData) < MAX_CHAR_DATA_LENGTH)
){
strncat(pData->szCharData,str,__min((unsigned int)len,MAX_CHAR_DATA_LENGTH-strlen(pData->szCharData)));
}
}
static void XMLCALL
stringEndElementHandle(void *userData, const char *name)
{
stringParseData * pData = (stringParseData *)userData;
if(pData->currentDepth <= pData->maxReadDepth) //we're at the end of an element that we've been reading
{
if(strcmp(name, "STRINGLIST") == 0)
{
pData->curElement = ELEMENT_NONE;
}
else if(strcmp(name, "STRING") == 0)
{
pData->curElement = ELEMENT;
if(pData->curIndex < pData->maxArraySize)
{
strcpy(AmmoCaliber[pData->curIndex],pData->szCharData);
}
}
pData->maxReadDepth--;
}
pData->currentDepth--;
}
BOOLEAN ReadInStringArray()
{
HWFILE hFile;
UINT32 uiBytesRead;
UINT32 uiFSize;
CHAR8 * lpcBuffer;
XML_Parser parser = XML_ParserCreate(NULL);
stringParseData pData;
DebugMsg(TOPIC_JA2, DBG_LEVEL_3, String("Loading %s",AMMOCALIBERSTRINGSFILENAME ) );
// Open strings file
hFile = FileOpen( AMMOCALIBERSTRINGSFILENAME, FILE_ACCESS_READ, FALSE );
if ( !hFile )
return( FALSE );
uiFSize = FileGetSize(hFile);
lpcBuffer = (CHAR8 *) MemAlloc(uiFSize+1);
//Read in block
if ( !FileRead( hFile, lpcBuffer, uiFSize, &uiBytesRead ) )
{
MemFree(lpcBuffer);
return( FALSE );
}
lpcBuffer[uiFSize] = 0; //add a null terminator
FileClose( hFile );
XML_SetElementHandler(parser, stringStartElementHandle, stringEndElementHandle);
XML_SetCharacterDataHandler(parser, stringCharacterDataHandle);
memset(&pData,0,sizeof(pData));
pData.maxArraySize = MAXITEMS;
pData.curIndex = -1;
XML_SetUserData(parser, &pData);
if(!XML_Parse(parser, lpcBuffer, uiFSize, TRUE))
{
CHAR8 errorBuf[511];
sprintf(errorBuf, "XML Parser Error in %s.xml: %s at line %d", AMMOCALIBERSTRINGSFILENAME, XML_ErrorString(XML_GetErrorCode(parser)), XML_GetCurrentLineNumber(parser));
LiveMessage(errorBuf);
MemFree(lpcBuffer);
return FALSE;
}
MemFree(lpcBuffer);
XML_ParserFree(parser);
return( TRUE );
}
BOOLEAN WriteStringArray()
{
HWFILE hFile;
DebugMsg(TOPIC_JA2, DBG_LEVEL_3, String("WriteStringArray"));
//Debug code; make sure that what we got from the file is the same as what's there
// Open a new file
hFile = FileOpen( "TABLEDATA\\AmmoCaliberStrings out.xml", FILE_ACCESS_WRITE | FILE_CREATE_ALWAYS, FALSE );
if ( !hFile )
return( FALSE );
{
UINT32 cnt;
FilePrintf(hFile,"<STRINGLIST>\r\n");
for(cnt = 0;cnt < 29;cnt++)
{
FilePrintf(hFile,"\t<STRING>");
UINT16 * szRemainder = AmmoCaliber[cnt]; //the remaining string to be output (for making valid XML)
while(szRemainder[0] != '\0')
{
UINT32 uiCharLoc = strcspn(szRemainder,"&<>\'\"\0");
UINT16 invChar = szRemainder[uiCharLoc];
if(uiCharLoc)
{
szRemainder[uiCharLoc] = '\0';
FilePrintf(hFile,"%s",szRemainder);
szRemainder[uiCharLoc] = invChar;
}
szRemainder += uiCharLoc;
switch(invChar)
{
case '&':
FilePrintf(hFile,"&amp;");
szRemainder++;
break;
case '<':
FilePrintf(hFile,"&lt;");
szRemainder++;
break;
case '>':
FilePrintf(hFile,"&gt;");
szRemainder++;
break;
case '\'':
FilePrintf(hFile,"&apos;");
szRemainder++;
break;
case '\"':
FilePrintf(hFile,"&quot;");
szRemainder++;
break;
}
}
// FilePrintf(hFile,"\t\t<STRING>%s</STRING>\r\n", AmmoCaliber[cnt]);
FilePrintf(hFile,"</STRING>\r\n");
}
FilePrintf(hFile,"</STRINGLIST>\r\n");
}
FileClose( hFile );
return( TRUE );
}
View File
+4007
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+71
View File
@@ -0,0 +1,71 @@
#ifdef PRECOMPILEDHEADERS
#include "Utils All.h"
#include "_Ja25Englishtext.h"
#else
#include "Language Defines.h"
#ifdef ENGLISH
#include "text.h"
#include "Fileman.h"
#endif
#endif
#ifdef ENGLISH
// VERY TRUNCATED FILE COPIED FROM JA2.5 FOR ITS FEATURES FOR JA2 GOLD
STR16 zNewTacticalMessages[]=
{
L"Range to target: %d tiles, Brightness = %d/%d",
L"Attaching the transmitter to your laptop computer.",
L"You cannot afford to hire %s",
L"For a limited time, the above fee covers the cost of the entire mission and includes the equipment listed below.",
L"Hire %s now and take advantage of our unprecedented 'one fee covers all' pricing. Also included in this unbelievable offer is the mercenary's personal equipment at no charge.",
L"Fee",
L"There is someone else in the sector...",
L"Gun Range: %d tiles, Chance to hit: %d percent",
L"Display Cover",
L"Line of Sight",
L"New Recruits cannot arrive there.",
L"Since your laptop has no transmitter, you won't be able to hire new team members. Perhaps this would be a good time to load a saved game or start over!",
L"%s hears the sound of crumpling metal coming from underneath Jerry's body. It sounds disturbingly like your laptop antenna being crushed.", //the %s is the name of a merc. @@@ Modified
L"After scanning the note left behind by Deputy Commander Morris, %s senses an oppurtinity. The note contains the coordinates for launching missiles against different towns in Arulco. It also gives the coodinates of the origin - the missile facility.",
L"Noticing the control panel, %s figures the numbers can be reveresed, so that the missile might destroy this very facility. %s needs to find an escape route. The elevator appears to offer the fastest solution...",
L"This is an IRON MAN game and you cannot save when enemies are around.", // @@@ new text
L"(Cannot save during combat)", //@@@@ new text
L"The current campaign name is greater than 30 characters.", // @@@ new text
L"The current campaign cannot be found.", // @@@ new text
L"Campaign: Default ( %S )", // @@@ new text
L"Campaign: %S", // @@@ new text
L"You have selected the campaign %S. This campaign is a player-modified version of the original Unfinished Business campaign. Are you sure you wish to play the %S campaign?", // @@@ new text
L"In order to use the editor, please select a campaign other than the default.", ///@@new
};
//these strings match up with the defines in IMP Skill trait.cpp
STR16 gzIMPSkillTraitsText[]=
{
L"Lock picking",
L"Hand to hand combat",
L"Electronics",
L"Night operations",
L"Throwing",
L"Teaching",
L"Heavy Weapons",
L"Auto Weapons",
L"Stealth",
L"Ambidextrous",
L"Knifing",
L"Rooftop Sniping",
L"Camouflage",
L"Martial Arts",
L"None",
L"I.M.P. Specialties",
};
//@@@: New string as of March 3, 2000.
STR16 gzIronManModeWarningText[]=
{
L"You have chosen IRON MAN mode. This setting makes the game considerably more challenging as you will not be able to save your game when in a sector occupied by enemies. This setting will affect the entire course of the game. Are you sure want to play in IRON MAN mode?",
};
#endif
+43
View File
@@ -0,0 +1,43 @@
#ifndef _JA25ENGLISHTEXT__H_
#define _JA25ENGLISHTEXT__H_
enum
{
TCTL_MSG__RANGE_TO_TARGET,
TCTL_MSG__ATTACH_TRANSMITTER_TO_LAPTOP,
TACT_MSG__CANNOT_AFFORD_MERC,
TACT_MSG__AIMMEMBER_FEE_TEXT,
TACT_MSG__AIMMEMBER_ONE_TIME_FEE,
TACT_MSG__FEE,
TACT_MSG__SOMEONE_ELSE_IN_SECTOR,
TCTL_MSG__GUN_RANGE_AND_CTH,
TCTL_MSG__DISPLAY_COVER,
TCTL_MSG__LOS,
TCTL_MSG__INVALID_DROPOFF_SECTOR,
TCTL_MSG__PLAYER_LOST_SHOULD_RESTART,
TCTL_MSG__JERRY_BREAKIN_LAPTOP_ANTENA,
TCTL_MSG__END_GAME_POPUP_TXT_1,
TCTL_MSG__END_GAME_POPUP_TXT_2,
TCTL_MSG__IRON_MAN_CANT_SAVE_NOW,
TCTL_MSG__CANNOT_SAVE_DURING_COMBAT,
TCTL_MSG__CAMPAIGN_NAME_TOO_LARGE,
TCTL_MSG__CAMPAIGN_DOESN_T_EXIST,
TCTL_MSG__DEFAULT_CAMPAIGN_LABEL,
TCTL_MSG__CAMPAIGN_LABEL,
TCTL_MSG__NEW_CAMPAIGN_CONFIRM,
TCTL_MSG__CANT_EDIT_DEFAULT,
};
extern STR16 zNewTacticalMessages[];
extern STR16 gzIMPSkillTraitsText[];
enum
{
IMM__IRON_MAN_MODE_WARNING_TEXT,
};
extern STR16 gzIronManModeWarningText[];
#endif
+50
View File
@@ -0,0 +1,50 @@
#ifdef PRECOMPILEDHEADERS
#include "Utils All.h"
#include "_Ja25EnglishText.h"
#else
#include "Language Defines.h"
#ifdef ENGLISH
#include "text.h"
#include "Fileman.h"
#endif
#endif
#ifdef GERMAN
// VERY TRUNCATED FILE COPIED FROM JA2.5 FOR ITS FEATURES FOR JA2 GOLD
STR16 zNewTacticalMessages[]=
{
L"Entfernung zum Ziel: %d Felder",
L"Verbinden Sie den Transmitter mit Ihrem Laptop-Computer.",
L"Sie haben nicht genug Geld, um %s anzuheuern",
L"Das obenstehende Honorar deckt für einen begrenzten Zeitraum die Kosten der Gesamtmission, und schließt untenstehendes Equipment mit ein.",
L"Engagieren Sie %s jetzt und nutzen Sie den Vorteil unseres beispiellosen 'Ein Betrag für alles'-Honorars. Das persönliche Equipment des Söldners ist gratis in diesem Preis mit inbegriffen.",
L"Honorar",
L"Da ist noch jemand im Sektor...",
L"Waffen-Rchwt.: %d Felder, Entf. zum Ziel: %d Felder",
L"Deckung anzeigen",
L"Sichtfeld",
L"Neue Rekruten können dort nicht hinkommen.",
L"Da Ihr Laptop keinen Transmitter besitzt, können Sie keine neuen Teammitglieder anheuern. Vielleicht ist dies eine guter Zeitpunkt, ein gespeichertes Spiel zu laden oder ein neues zu starten!",
L"%s hört das Geräusch knirschenden Metalls unter Jerry hervordringen. Es klingt grässlich - die Antenne ihres Laptop-Computers ist zerstört.", //the %s is the name of a merc. @@@ Modified
L"Nach Ansehen des Hinweises, den Commander Morris hinterließ, erkennt %s eine einmalige Gelegenheit. Der Hinweis enthält Koordinaten für den Start von Raketen gegen verschiedene Städte in Arulco. Aber er enthält auch die Koordinaten des Startpunktes - der Raketenanlage.",
L"Das Kontroll-Board studierend, entdeckt %s, dass die Zahlen umgedreht werden könnten, so dass die Raketen diese Anlage selbst zerstören. %s muss nun einen Fluchtweg finden. Der Aufzug scheint die schnellstmögliche Route zu bieten...", //!!! The original reads: L"Noticing the control panel %s, figures the numbers can be reversed..." That sounds odd for me, but I think the comma is placed one word too late... (correct?)
L"Dies ist ein IRON MAN-Spiel, und es kann nicht gespeichert werden, wenn sich Gegner in der Nähe befinden.",
L"(Kann während Kampf nicht speichern)",
L"Der Name der aktuellen Kampagne enthält mehr als 30 Buchstaben.",
L"Die aktuelle Kampagne kann nicht gefunden werden.",
L"Kampagne: Standard ( %S )",
L"Kampagne: %S",
L"Sie haben die Kampagne %S gewählt. Diese ist eine vom Spieler modifizierte Version der Originalkampagne von JA2UB. Möchten Sie die Kampagne %S spielen?",
L"Um den Editor zu benutzen, müssen Sie eine andere als die Standardkampgane auswählen.",
};
//@@@: New string as of March 3, 2000.
STR16 gzIronManModeWarningText[]=
{
L"You have chosen IRON MAN mode. This setting makes the game considerably more challenging as you will not be able to save your game when in a sector occupied by enemies. This setting will affect the entire course of the game. Are you sure want to play in IRON MAN mode?",
};
#endif
+42
View File
@@ -0,0 +1,42 @@
#ifndef _JA25GERMANTEXT__H_
#define _JA25GERMANTEXT__H_
enum
{
TCTL_MSG__RANGE_TO_TARGET,
TCTL_MSG__ATTACH_TRANSMITTER_TO_LAPTOP,
TACT_MSG__CANNOT_AFFORD_MERC,
TACT_MSG__AIMMEMBER_FEE_TEXT,
TACT_MSG__AIMMEMBER_ONE_TIME_FEE,
TACT_MSG__FEE,
TACT_MSG__SOMEONE_ELSE_IN_SECTOR,
TCTL_MSG__RANGE_TO_TARGET_AND_GUN_RANGE,
TCTL_MSG__DISPLAY_COVER,
TCTL_MSG__LOS,
TCTL_MSG__INVALID_DROPOFF_SECTOR,
TCTL_MSG__PLAYER_LOST_SHOULD_RESTART,
TCTL_MSG__JERRY_BREAKIN_LAPTOP_ANTENA,
TCTL_MSG__END_GAME_POPUP_TXT_1,
TCTL_MSG__END_GAME_POPUP_TXT_2,
TCTL_MSG__IRON_MAN_CANT_SAVE_NOW,
TCTL_MSG__CANNOT_SAVE_DURING_COMBAT,
TCTL_MSG__CAMPAIGN_NAME_TOO_LARGE,
TCTL_MSG__CAMPAIGN_DOESN_T_EXIST,
TCTL_MSG__DEFAULT_CAMPAIGN_LABEL,
TCTL_MSG__CAMPAIGN_LABEL,
TCTL_MSG__NEW_CAMPAIGN_CONFIRM,
TCTL_MSG__CANT_EDIT_DEFAULT,
};
extern STR16 zNewTacticalMessages[];
enum
{
IMM__IRON_MAN_MODE_WARNING_TEXT,
};
extern STR16 gzIronManModeWarningText[];
#endif
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+381
View File
@@ -0,0 +1,381 @@
// THIS MODULE IS TEMPORARY - USED FOR OUR SOUND SYSTEM INTIL IT IS IMPLEMENTED FOR THE SGP
// TAKEN FROM MS SAMPLES FOR DirectSound
#ifdef PRECOMPILEDHEADERS
#include "Utils All.h"
#include <windows.h>
#include <windowsx.h>
#include <mmsystem.h>
#include <dsound.h>
#else
#include "types.h"
#include <windows.h>
#include <windowsx.h>
#include <mmsystem.h>
#include <dsound.h>
#endif
#define WIN32_LEAN_AND_MEAN
typedef struct
{
BYTE *pbWaveData; // pointer into wave resource (for restore)
DWORD cbWaveSize; // size of wave data (for restore)
int iAlloc; // number of buffers.
int iCurrent; // current buffer
IDirectSoundBuffer* Buffers[1]; // list of buffers
} SNDOBJ, *HSNDOBJ;
#define _HSNDOBJ_DEFINED
#include "dsutil.h"
static const char c_szWAV[] = "WAVE";
///////////////////////////////////////////////////////////////////////////////
//
// DSLoadSoundBuffer
//
///////////////////////////////////////////////////////////////////////////////
IDirectSoundBuffer *DSLoadSoundBuffer(IDirectSound *pDS, LPCTSTR lpName)
{
IDirectSoundBuffer *pDSB = NULL;
DSBUFFERDESC dsBD = {0};
BYTE *pbWaveData;
if (DSGetWaveResource(NULL, lpName, &dsBD.lpwfxFormat, &pbWaveData, &dsBD.dwBufferBytes))
{
dsBD.dwSize = sizeof(dsBD);
dsBD.dwFlags = DSBCAPS_STATIC | DSBCAPS_CTRLDEFAULT; // | DSBCAPS_GETCURRENTPOSITION2;
if (SUCCEEDED(IDirectSound_CreateSoundBuffer(pDS, &dsBD, &pDSB, NULL)))
{
if (!DSFillSoundBuffer(pDSB, pbWaveData, dsBD.dwBufferBytes))
{
IDirectSoundBuffer_Release(pDSB);
pDSB = NULL;
}
}
else
{
pDSB = NULL;
}
}
return pDSB;
}
///////////////////////////////////////////////////////////////////////////////
//
// DSReloadSoundBuffer
//
///////////////////////////////////////////////////////////////////////////////
BOOL DSReloadSoundBuffer(IDirectSoundBuffer *pDSB, LPCTSTR lpName)
{
BOOL result=FALSE;
BYTE *pbWaveData;
DWORD cbWaveSize;
if (DSGetWaveResource(NULL, lpName, NULL, &pbWaveData, &cbWaveSize))
{
if (SUCCEEDED(IDirectSoundBuffer_Restore(pDSB)) &&
DSFillSoundBuffer(pDSB, pbWaveData, cbWaveSize))
{
result = TRUE;
}
}
return result;
}
///////////////////////////////////////////////////////////////////////////////
//
// DSGetWaveResource
//
///////////////////////////////////////////////////////////////////////////////
BOOL DSGetWaveResource(HMODULE hModule, LPCTSTR lpName,
WAVEFORMATEX **ppWaveHeader, BYTE **ppbWaveData, DWORD *pcbWaveSize)
{
HRSRC hResInfo;
HGLOBAL hResData;
void *pvRes;
if (((hResInfo = FindResource(hModule, lpName, c_szWAV)) != NULL) &&
((hResData = LoadResource(hModule, hResInfo)) != NULL) &&
((pvRes = LockResource(hResData)) != NULL) &&
DSParseWaveResource(pvRes, ppWaveHeader, ppbWaveData, pcbWaveSize))
{
return TRUE;
}
return FALSE;
}
///////////////////////////////////////////////////////////////////////////////
// SndObj fns
///////////////////////////////////////////////////////////////////////////////
SNDOBJ *SndObjCreate(IDirectSound *pDS, LPCTSTR lpName, int iConcurrent)
{
SNDOBJ *pSO = NULL;
LPWAVEFORMATEX pWaveHeader;
BYTE *pbData;
UINT cbData;
if (DSGetWaveResource(NULL, lpName, &pWaveHeader, &pbData, (DWORD *)&cbData))
{
if (iConcurrent < 1)
iConcurrent = 1;
if ((pSO = (SNDOBJ *)LocalAlloc(LPTR, sizeof(SNDOBJ) +
(iConcurrent-1) * sizeof(IDirectSoundBuffer *))) != NULL)
{
int i;
pSO->iAlloc = iConcurrent;
pSO->pbWaveData = pbData;
pSO->cbWaveSize = cbData;
pSO->Buffers[0] = DSLoadSoundBuffer(pDS, lpName);
for (i=1; i<pSO->iAlloc; i++)
{
if (FAILED(IDirectSound_DuplicateSoundBuffer(pDS,
pSO->Buffers[0], &pSO->Buffers[i])))
{
pSO->Buffers[i] = DSLoadSoundBuffer(pDS, lpName);
if (!pSO->Buffers[i]) {
SndObjDestroy(pSO);
pSO = NULL;
break;
}
}
}
}
}
return pSO;
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
void SndObjDestroy(SNDOBJ *pSO)
{
if (pSO)
{
int i;
for (i=0; i<pSO->iAlloc; i++)
{
if (pSO->Buffers[i])
{
IDirectSoundBuffer_Release(pSO->Buffers[i]);
pSO->Buffers[i] = NULL;
}
}
LocalFree((HANDLE)pSO);
}
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
IDirectSoundBuffer *SndObjGetFreeBuffer(SNDOBJ *pSO)
{
IDirectSoundBuffer *pDSB;
if (pSO == NULL)
return NULL;
if (pDSB = pSO->Buffers[pSO->iCurrent])
{
HRESULT hres;
DWORD dwStatus;
hres = IDirectSoundBuffer_GetStatus(pDSB, &dwStatus);
if (FAILED(hres))
dwStatus = 0;
if ((dwStatus & DSBSTATUS_PLAYING) == DSBSTATUS_PLAYING)
{
if (pSO->iAlloc > 1)
{
if (++pSO->iCurrent >= pSO->iAlloc)
pSO->iCurrent = 0;
pDSB = pSO->Buffers[pSO->iCurrent];
hres = IDirectSoundBuffer_GetStatus(pDSB, &dwStatus);
if (SUCCEEDED(hres) && (dwStatus & DSBSTATUS_PLAYING) == DSBSTATUS_PLAYING)
{
IDirectSoundBuffer_Stop(pDSB);
IDirectSoundBuffer_SetCurrentPosition(pDSB, 0);
}
}
else
{
pDSB = NULL;
}
}
if (pDSB && (dwStatus & DSBSTATUS_BUFFERLOST))
{
if (FAILED(IDirectSoundBuffer_Restore(pDSB)) ||
!DSFillSoundBuffer(pDSB, pSO->pbWaveData, pSO->cbWaveSize))
{
pDSB = NULL;
}
}
}
return pDSB;
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
BOOL SndObjPlay(SNDOBJ *pSO, DWORD dwPlayFlags)
{
BOOL result = FALSE;
if (pSO == NULL)
return FALSE;
if ((!(dwPlayFlags & DSBPLAY_LOOPING) || (pSO->iAlloc == 1)))
{
IDirectSoundBuffer *pDSB = SndObjGetFreeBuffer(pSO);
if (pDSB != NULL) {
result = SUCCEEDED(IDirectSoundBuffer_Play(pDSB, 0, 0, dwPlayFlags));
}
}
return result;
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
BOOL SndObjStop(SNDOBJ *pSO)
{
int i;
if (pSO == NULL)
return FALSE;
for (i=0; i<pSO->iAlloc; i++)
{
IDirectSoundBuffer_Stop(pSO->Buffers[i]);
IDirectSoundBuffer_SetCurrentPosition(pSO->Buffers[i], 0);
}
return TRUE;
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
BOOL DSFillSoundBuffer(IDirectSoundBuffer *pDSB, BYTE *pbWaveData, DWORD cbWaveSize)
{
if (pDSB && pbWaveData && cbWaveSize)
{
LPVOID pMem1, pMem2;
DWORD dwSize1, dwSize2;
if (SUCCEEDED(IDirectSoundBuffer_Lock(pDSB, 0, cbWaveSize,
&pMem1, &dwSize1, &pMem2, &dwSize2, 0)))
{
CopyMemory(pMem1, pbWaveData, dwSize1);
if ( 0 != dwSize2 )
CopyMemory(pMem2, pbWaveData+dwSize1, dwSize2);
IDirectSoundBuffer_Unlock(pDSB, pMem1, dwSize1, pMem2, dwSize2);
return TRUE;
}
}
return FALSE;
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
BOOL DSParseWaveResource(void *pvRes, WAVEFORMATEX **ppWaveHeader, BYTE **ppbWaveData,DWORD *pcbWaveSize)
{
DWORD *pdw;
DWORD *pdwEnd;
DWORD dwRiff;
DWORD dwType;
DWORD dwLength;
if (ppWaveHeader)
*ppWaveHeader = NULL;
if (ppbWaveData)
*ppbWaveData = NULL;
if (pcbWaveSize)
*pcbWaveSize = 0;
pdw = (DWORD *)pvRes;
dwRiff = *pdw++;
dwLength = *pdw++;
dwType = *pdw++;
if (dwRiff != mmioFOURCC('R', 'I', 'F', 'F'))
goto exit; // not even RIFF
if (dwType != mmioFOURCC('W', 'A', 'V', 'E'))
goto exit; // not a WAV
pdwEnd = (DWORD *)((BYTE *)pdw + dwLength-4);
while (pdw < pdwEnd)
{
dwType = *pdw++;
dwLength = *pdw++;
switch (dwType)
{
case mmioFOURCC('f', 'm', 't', ' '):
if (ppWaveHeader && !*ppWaveHeader)
{
if (dwLength < sizeof(WAVEFORMAT))
goto exit; // not a WAV
*ppWaveHeader = (WAVEFORMATEX *)pdw;
if ((!ppbWaveData || *ppbWaveData) &&
(!pcbWaveSize || *pcbWaveSize))
{
return TRUE;
}
}
break;
case mmioFOURCC('d', 'a', 't', 'a'):
if ((ppbWaveData && !*ppbWaveData) ||
(pcbWaveSize && !*pcbWaveSize))
{
if (ppbWaveData)
*ppbWaveData = (LPBYTE)pdw;
if (pcbWaveSize)
*pcbWaveSize = dwLength;
if (!ppWaveHeader || *ppWaveHeader)
return TRUE;
}
break;
}
pdw = (DWORD *)((BYTE *)pdw + ((dwLength+1)&~1));
}
exit:
return FALSE;
}
+215
View File
@@ -0,0 +1,215 @@
/*==========================================================================
*
* Copyright (C) 1995 Microsoft Corporation. All Rights Reserved.
*
* File: dsutil.cpp
* Content: Routines for dealing with sounds from resources
*
*
***************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
///////////////////////////////////////////////////////////////////////////////
//
// DSLoadSoundBuffer Loads an IDirectSoundBuffer from a Win32 resource in
// the current application.
//
// Params:
// pDS -- Pointer to an IDirectSound that will be used to create
// the buffer.
//
// lpName -- Name of WAV resource to load the data from. Can be a
// resource id specified using the MAKEINTRESOURCE macro.
//
// Returns an IDirectSoundBuffer containing the wave data or NULL on error.
//
// example:
// in the application's resource script (.RC file)
// Turtle WAV turtle.wav
//
// some code in the application:
// IDirectSoundBuffer *pDSB = DSLoadSoundBuffer(pDS, "Turtle");
//
// if (pDSB)
// {
// IDirectSoundBuffer_Play(pDSB, 0, 0, DSBPLAY_TOEND);
// /* ... */
//
///////////////////////////////////////////////////////////////////////////////
IDirectSoundBuffer *DSLoadSoundBuffer(IDirectSound *pDS, LPCTSTR lpName);
///////////////////////////////////////////////////////////////////////////////
//
// DSReloadSoundBuffer Reloads an IDirectSoundBuffer from a Win32 resource in
// the current application. normally used to handle
// a DSERR_BUFFERLOST error.
// Params:
// pDSB -- Pointer to an IDirectSoundBuffer to be reloaded.
//
// lpName -- Name of WAV resource to load the data from. Can be a
// resource id specified using the MAKEINTRESOURCE macro.
//
// Returns a BOOL indicating whether the buffer was successfully reloaded.
//
// example:
// in the application's resource script (.RC file)
// Turtle WAV turtle.wav
//
// some code in the application:
// TryAgain:
// HRESULT hres = IDirectSoundBuffer_Play(pDSB, 0, 0, DSBPLAY_TOEND);
//
// if (FAILED(hres))
// {
// if ((hres == DSERR_BUFFERLOST) &&
// DSReloadSoundBuffer(pDSB, "Turtle"))
// {
// goto TryAgain;
// }
// /* deal with other errors... */
// }
//
///////////////////////////////////////////////////////////////////////////////
BOOL DSReloadSoundBuffer(IDirectSoundBuffer *pDSB, LPCTSTR lpName);
///////////////////////////////////////////////////////////////////////////////
//
// DSGetWaveResource Finds a WAV resource in a Win32 module.
//
// Params:
// hModule -- Win32 module handle of module containing WAV resource.
// Pass NULL to indicate current application.
//
// lpName -- Name of WAV resource to load the data from. Can be a
// resource id specified using the MAKEINTRESOURCE macro.
//
// ppWaveHeader-- Optional pointer to WAVEFORMATEX * to receive a pointer to
// the WAVEFORMATEX header in the specified WAV resource.
// Pass NULL if not required.
//
// ppbWaveData -- Optional pointer to BYTE * to receive a pointer to the
// waveform data in the specified WAV resource. Pass NULL if
// not required.
//
// pdwWaveSize -- Optional pointer to DWORD to receive the size of the
// waveform data in the specified WAV resource. Pass NULL if
// not required.
//
// Returns a BOOL indicating whether a valid WAV resource was found.
//
///////////////////////////////////////////////////////////////////////////////
BOOL DSGetWaveResource(HMODULE hModule, LPCTSTR lpName,
WAVEFORMATEX **ppWaveHeader, BYTE **ppbWaveData, DWORD *pdwWaveSize);
///////////////////////////////////////////////////////////////////////////////
//
// HSNDOBJ Handle to a SNDOBJ object.
//
// SNDOBJs are implemented in dsutil as an example layer built on top
// of DirectSound.
//
// A SNDOBJ is generally used to manage individual
// sounds which need to be played multiple times concurrently. A
// SNDOBJ represents a queue of IDirectSoundBuffer objects which
// all refer to the same buffer memory.
//
// A SNDOBJ also automatically reloads the sound resource when
// DirectSound returns a DSERR_BUFFERLOST
//
///////////////////////////////////////////////////////////////////////////////
#ifndef _HSNDOBJ_DEFINED
DECLARE_HANDLE32(HSNDOBJ);
#endif
///////////////////////////////////////////////////////////////////////////////
//
// SndObjCreate Loads a SNDOBJ from a Win32 resource in
// the current application.
//
// Params:
// pDS -- Pointer to an IDirectSound that will be used to create
// the SNDOBJ.
//
// lpName -- Name of WAV resource to load the data from. Can be a
// resource id specified using the MAKEINTRESOURCE macro.
//
// iConcurrent -- Integer representing the number of concurrent playbacks of
// to plan for. Attempts to play more than this number will
// succeed but will restart the least recently played buffer
// even if it is not finished playing yet.
//
// Returns an HSNDOBJ or NULL on error.
//
// NOTES:
// SNDOBJs automatically restore and reload themselves as required.
//
///////////////////////////////////////////////////////////////////////////////
HSNDOBJ SndObjCreate(IDirectSound *pDS, LPCTSTR lpName, int iConcurrent);
///////////////////////////////////////////////////////////////////////////////
//
// SndObjDestroy Frees a SNDOBJ and releases all of its buffers.
//
// Params:
// hSO -- Handle to a SNDOBJ to free.
//
///////////////////////////////////////////////////////////////////////////////
void SndObjDestroy(HSNDOBJ hSO);
///////////////////////////////////////////////////////////////////////////////
//
// SndObjPlay Plays a buffer in a SNDOBJ.
//
// Params:
// hSO -- Handle to a SNDOBJ to play a buffer from.
//
// dwPlayFlags -- Flags to pass to IDirectSoundBuffer::Play. It is not
// legal to play an SndObj which has more than one buffer
// with the DSBPLAY_LOOPING flag. Pass 0 to stop playback.
//
///////////////////////////////////////////////////////////////////////////////
BOOL SndObjPlay(HSNDOBJ hSO, DWORD dwPlayFlags);
///////////////////////////////////////////////////////////////////////////////
//
// SndObjStop Stops one or more buffers in a SNDOBJ.
//
// Params:
// hSO -- Handle to a SNDOBJ to play a buffer from.
//
///////////////////////////////////////////////////////////////////////////////
BOOL SndObjStop(HSNDOBJ hSO);
///////////////////////////////////////////////////////////////////////////////
//
// SndObjGetFreeBuffer returns one of the cloned buffers that is
// not currently playing
//
// Params:
// hSO -- Handle to a SNDOBJ
//
// NOTES:
// This function is provided so that callers can set things like pan etc
// before playing the buffer.
//
// EXAMPLE:
// ...
//
///////////////////////////////////////////////////////////////////////////////
IDirectSoundBuffer *SndObjGetFreeBuffer(HSNDOBJ hSO);
///////////////////////////////////////////////////////////////////////////////
//
// helper routines
//
///////////////////////////////////////////////////////////////////////////////
BOOL DSFillSoundBuffer(IDirectSoundBuffer *pDSB, BYTE *pbWaveData, DWORD dwWaveSize);
BOOL DSParseWaveResource(void *pvRes, WAVEFORMATEX **ppWaveHeader, BYTE **ppbWaveData, DWORD *pdwWaveSize);
#ifdef __cplusplus
}
#endif
+8
View File
@@ -0,0 +1,8 @@
#ifdef JA2EDITOR
#ifndef __MAPUTILITY_H
#define __MAPUTILITY_H
#endif
#endif
+1882
View File
File diff suppressed because it is too large Load Diff
+108
View File
@@ -0,0 +1,108 @@
#ifndef __MESSAGE_H
#define __MESSAGE_H
//#include "sgp.h"
#include "font.h"
#include "Font Control.h"
#include "types.h"
#include "Fileman.h"
struct stringstruct{
STR16 pString16;
INT32 iVideoOverlay;
UINT32 uiFont;
UINT16 usColor;
UINT32 uiFlags;
BOOLEAN fBeginningOfNewString;
UINT32 uiTimeOfLastUpdate;
UINT32 uiPadding[ 5 ];
struct stringstruct *pNext;
struct stringstruct *pPrev;
};
#define MSG_INTERFACE 0
#define MSG_DIALOG 1
#define MSG_CHAT 2
#define MSG_DEBUG 3
#define MSG_UI_FEEDBACK 4
#define MSG_ERROR 5
#define MSG_BETAVERSION 6
#define MSG_TESTVERSION 7
#define MSG_MAP_UI_POSITION_MIDDLE 8
#define MSG_MAP_UI_POSITION_UPPER 9
#define MSG_MAP_UI_POSITION_LOWER 10
#define MSG_SKULL_UI_FEEDBACK 11
// These defines correlate to defines in font.h
#define MSG_FONT_RED FONT_MCOLOR_RED
#define MSG_FONT_YELLOW FONT_MCOLOR_LTYELLOW
#define MSG_FONT_WHITE FONT_MCOLOR_WHITE
typedef struct stringstruct ScrollStringSt;
typedef ScrollStringSt *ScrollStringStPtr;
extern ScrollStringStPtr pStringS;
extern UINT32 StringCount;
extern UINT8 gubCurrentMapMessageString;
extern BOOLEAN fDisableJustForIan;
// are we allowed to beep on message scroll in tactical
extern BOOLEAN fOkToBeepNewMessage;
void ScreenMsg( UINT16 usColor, UINT8 ubPriority, STR16 pStringA, ...);
// same as screen message, but only display to mapscreen message system, not tactical
void MapScreenMessage( UINT16 usColor, UINT8 ubPriority, STR16 pStringA, ...);
void ScrollString( void );
void DisplayStringsInMapScreenMessageList( void );
void InitGlobalMessageList( void );
void FreeGlobalMessageList( void );
UINT8 GetRangeOfMapScreenMessages( void );
void EnableDisableScrollStringVideoOverlay( BOOLEAN fEnable );
// will go and clear all displayed strings off the screen
void ClearDisplayedListOfTacticalStrings( void );
// clear ALL strings in the tactical Message Queue
void ClearTacticalMessageQueue( void );
BOOLEAN LoadMapScreenMessagesFromSaveGameFile( HWFILE hFile );
BOOLEAN SaveMapScreenMessagesToSaveGameFile( HWFILE hFile );
// use these if you are not Kris
void HideMessagesDuringNPCDialogue( void );
void UnHideMessagesDuringNPCDialogue( void );
// disable and enable scroll string, only to be used by Kris
void DisableScrollMessages( void );
void EnableScrollMessages( void );
/* unused functions, written by Mr. Carter, so don't expect these to work...
UINT8 GetTheRelativePositionOfCurrentMessage( void );
void MoveCurrentMessagePointerDownList( void );
void MoveCurrentMessagePointerUpList( void );
void ScrollToHereInMapScreenMessageList( UINT8 ubPosition );
BOOLEAN IsThereAnEmptySlotInTheMapScreenMessageList( void );
UINT8 GetFirstEmptySlotInTheMapScreenMessageList( void );
void RemoveMapScreenMessageListString( ScrollStringStPtr pStringSt );
BOOLEAN AreThereASetOfStringsAfterThisIndex( UINT8 ubMsgIndex, INT32 iNumberOfStrings );
UINT8 GetCurrentMessageValue( void );
UINT8 GetCurrentTempMessageValue( void );
UINT8 GetNewMessageValueGivenPosition( UINT8 ubPosition );
BOOLEAN IsThisTheLastMessageInTheList( void );
BOOLEAN IsThisTheFirstMessageInTheList( void );
void DisplayLastMessage( void );
*/
#endif