New feature: Voicesets are now independent fom profile slots. Voiceset is set in MercProfiles.xml with <usVoiceIndex>. IMP voices are defined in IMPVoices.xml.

This feature is savegame compatible.

Requires GameDir >= r2357

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8364 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2017-01-14 20:20:11 +00:00
parent e2c05ce1c6
commit efd9ab4723
30 changed files with 425 additions and 462 deletions
+1 -4
View File
@@ -130,16 +130,13 @@ void BtnIMPCancelCallback(GUI_BUTTON *btn,INT32 reason);
BOOLEAN HasTheCurrentIMPPageBeenVisited( void );
extern void SetAttributes( void );
void GameInitCharProfile()
{
LaptopSaveInfo.iIMPIndex = 0;
iCurrentPortrait = 0;
iCurrentProfileMode = 0;
// iCurrentVoice = 0;
iSelectedIMPVoiceSet = 0;
iPortraitNumber = 0;
return;
}
void EnterCharProfile()
-12
View File
@@ -197,18 +197,6 @@ void EnterIMPAttributeSelection( void )
gpCurrentScrollBox = NULL;
giCurrentlySelectedStat = -1;
// does character have PROBLEMS!!?!?!
/*
if( DoesCharacterHaveAnAttitude() )
{
iCurrentBonusPoints+= 10;
}
if( DoesCharacterHaveAPersoanlity( ) )
{
iCurrentBonusPoints += 10;
}
*/
}
fReturnStatus = TRUE;
fFirstIMPAttribTime = FALSE;
-104
View File
@@ -186,110 +186,6 @@ void EnterIMPColorChoice( void )
bBigBody = gIMPValues[iPortraitNumber].bBigBody;
}
// Based on the portrait chosen, set the default colors, when colors
/* switch( iPortraitNumber )
{
case( 0 ):
iCurrentSkin = 3;
iCurrentHair = 0;
iCurrentShirt = 7;
iCurrentPants = 2;
bBigBody = TRUE;
break;
case( 1 ):
iCurrentSkin = 1;
iCurrentHair = 0;
iCurrentShirt = 4;
iCurrentPants = 3;
break;
case( 2 ):
iCurrentSkin = 1;
iCurrentHair = 0;
iCurrentShirt = 0;
iCurrentPants = 0;
break;
case( 3 ):
iCurrentSkin = 2;
iCurrentHair = 0;
iCurrentShirt = 0;
iCurrentPants = 1;
break;
case( 4 ):
iCurrentSkin = 1;
iCurrentHair = 0;
iCurrentShirt = 3;
iCurrentPants = 5;
break;
case( 5 ):
iCurrentSkin = 2;
iCurrentHair = 1;
iCurrentShirt = 3;
iCurrentPants = 1;
break;
case( 6 ):
iCurrentSkin = 1;
iCurrentHair = 0;
iCurrentShirt = 4;
iCurrentPants = 0;
bBigBody = TRUE;
break;
case( 7 ):
iCurrentSkin = 1;
iCurrentHair = 0;
iCurrentShirt = 10;
iCurrentPants = 1;
bBigBody = TRUE;
break;
case( 8 ):
iCurrentSkin = 1;
iCurrentHair = 0;
iCurrentShirt = 4;
iCurrentPants = 3;
break;
case( 9 ):
iCurrentSkin = 0;
iCurrentHair = 0;
iCurrentShirt = 4;
iCurrentPants = 4;
break;
case( 10 ):
iCurrentSkin = 1;
iCurrentHair = 1;
iCurrentShirt = 4;
iCurrentPants = 1;
break;
case( 11 ):
iCurrentSkin = 1;
iCurrentHair = 1;
iCurrentShirt = 10;
iCurrentPants = 1;
break;
case( 12 ):
iCurrentSkin = 0;
iCurrentHair = 0;
iCurrentShirt = 0;
iCurrentPants = 5;
break;
case( 13 ):
iCurrentSkin = 3;
iCurrentHair = 0;
iCurrentShirt = 3;
iCurrentPants = 1;
break;
case( 14 ):
iCurrentSkin = 1;
iCurrentHair = 4;
iCurrentShirt = 0;
iCurrentPants = 2;
break;
case( 15 ):
iCurrentSkin = 1;
iCurrentHair = 3;
iCurrentShirt = 4;
iCurrentPants = 5;
break;
}
*/
//add the buttons
AddIMPColorChoiceButtons();
+21 -93
View File
@@ -27,6 +27,7 @@
#include "IMP Disability Trait.h"
#include "IMP Color Choosing.h"
#include "IMP Minor Trait.h"
#include "IMP Voices.h"
#endif
#include "IMP Confirm.h"
@@ -116,17 +117,24 @@ void SetMercSkinAndHairColors( void );
BOOLEAN ShouldThisMercHaveABigBody( void );
void CreateACharacterFromPlayerEnteredStats( void )
{
// Kaiden: Seems like as good a place as any to stash this function call to
// ensure that these lists don't get overwritten or Nulled due to the amount
// of changes and revisions that have been made to personalities and attitudes.
CreatePlayersPersonalitySkillsAndAttitude();
// Flugente: as the profile is no longer identical to the voice set, we need to determine a free slot
INT32 impslot = 0;
if ( fCharacterIsMale )
impslot = GetFirstMaleSlot( );
else
impslot = GetFirstFemaleSlot( );
INT32 impid = gGameExternalOptions.iaIMPSlots[impslot];
LaptopSaveInfo.iIMPIndex = GetFreeIMPSlot( impid, -1 );
// copy over full name
wcscpy( gMercProfiles[ LaptopSaveInfo.iIMPIndex ].zName, pFullName );
@@ -144,8 +152,7 @@ void CreateACharacterFromPlayerEnteredStats( void )
// female
gMercProfiles[ LaptopSaveInfo.iIMPIndex ].bSex = FEMALE;
}
// attributes
gMercProfiles[ LaptopSaveInfo.iIMPIndex ].bLifeMax = ( INT8 )iHealth;
gMercProfiles[ LaptopSaveInfo.iIMPIndex ].bLife = ( INT8 )iHealth;
@@ -154,15 +161,13 @@ void CreateACharacterFromPlayerEnteredStats( void )
gMercProfiles[ LaptopSaveInfo.iIMPIndex ].bDexterity = ( INT8 )iDexterity;
gMercProfiles[ LaptopSaveInfo.iIMPIndex ].bWisdom = ( INT8 )iWisdom;
gMercProfiles[ LaptopSaveInfo.iIMPIndex ].bLeadership = ( INT8 )iLeadership;
// skills
gMercProfiles[ LaptopSaveInfo.iIMPIndex ].bMarksmanship = ( INT8 )iMarksmanship;
gMercProfiles[ LaptopSaveInfo.iIMPIndex ].bMedical = ( INT8 )iMedical;
gMercProfiles[ LaptopSaveInfo.iIMPIndex ].bMechanical = ( INT8 )iMechanical;
gMercProfiles[ LaptopSaveInfo.iIMPIndex ].bExplosive = ( INT8 )iExplosives;
// personality
gMercProfiles[ LaptopSaveInfo.iIMPIndex ].bDisability = ( INT8 )iPersonality;
@@ -176,7 +181,7 @@ void CreateACharacterFromPlayerEnteredStats( void )
// Flugente: background
gMercProfiles[ LaptopSaveInfo.iIMPIndex ].usBackground = usBackground;
// Flugente: sexism, racsim etc.
// Flugente: sexism, racism etc.
gMercProfiles[ LaptopSaveInfo.iIMPIndex ].bRace = ( INT8 )bRace;
gMercProfiles[ LaptopSaveInfo.iIMPIndex ].bNationality = ( INT8 )bNationality;
gMercProfiles[ LaptopSaveInfo.iIMPIndex ].bAppearance = ( INT8 )bAppearance;
@@ -187,6 +192,10 @@ void CreateACharacterFromPlayerEnteredStats( void )
gMercProfiles[ LaptopSaveInfo.iIMPIndex ].bHatedNationalityCareLevel = ( INT8 )bHatedNationalityCareLevel;
gMercProfiles[ LaptopSaveInfo.iIMPIndex ].bRacist = ( INT8 )bRacist;
gMercProfiles[ LaptopSaveInfo.iIMPIndex ].bSexist = ( UINT8 )bSexist;
// Flugente: voice set used
gMercProfiles[LaptopSaveInfo.iIMPIndex].usVoiceIndex = iSelectedIMPVoiceSet;
// WDS: Advanced start
//gMercProfiles[ LaptopSaveInfo.iIMPIndex ].bExpLevel = gGameExternalOptions.ubIMPStartingLevel;
@@ -201,69 +210,6 @@ void CreateACharacterFromPlayerEnteredStats( void )
// Option for badass added - SANDRO
if (bBadAssSelected())
gMercProfiles[ LaptopSaveInfo.iIMPIndex ].uiBodyTypeSubFlags = 1;
return;
}
BOOLEAN DoesCharacterHaveAnAttitude( void )
{
// simply checks if caracter has an attitude other than normal
switch( iAttitude )
{
case ATT_LONER:
case ATT_PESSIMIST:
case ATT_ARROGANT:
case ATT_BIG_SHOT:
case ATT_ASSHOLE:
case ATT_COWARD:
return( TRUE );
default:
return( FALSE );
}
}
BOOLEAN DoesCharacterHaveAPersoanlity( void )
{
if( iPersonality != NO_DISABILITY )
{
// yep
return ( TRUE );
}
else
{
// nope
return ( FALSE );
}
// Kaiden: Following is the original UB section:
// The fist return( FALSE ); Statement was the only
// thing uncommented.
/*
// only one we can get is PSYCHO, and that is not much of a penalty
return( FALSE );
// simply checks if caracter has a personality other than normal
if( iPersonality != NO_DISABILITY )
{
// yep
return ( TRUE );
}
else
{
// nope
return ( FALSE );
}
*/
}
void CreatePlayerAttitude( void )
@@ -286,8 +232,6 @@ void AddAnAttitudeToAttitudeList( INT8 bAttitude )
// increment attitude list counter
iLastElementInAttitudeList++;
}
return;
}
@@ -317,8 +261,6 @@ void ClearAllSkillsList( void )
iLastElementInSkillsList = 0;
}
void RemoveSkillFromSkillsList( INT32 iIndex )
{
INT32 iLoop;
@@ -348,9 +290,7 @@ void RemoveSkillFromSkillsList( INT32 iIndex )
INT32 FindSkillInSkillsList( INT32 iSkill )
{
INT32 iLoop;
for ( iLoop = 0; iLoop < iLastElementInSkillsList; iLoop++ )
for ( INT32 iLoop = 0; iLoop < iLastElementInSkillsList; iLoop++ )
{
if ( SkillsList[ iLoop ] == iSkill )
{
@@ -389,7 +329,6 @@ void ValidateSkillsList( void )
if ( iIndex != -1 )
pProfile->bMechanical = 1;
}
}
// SANDRO - added to give 1 medical skill to doctors
@@ -506,8 +445,6 @@ void AddAPersonalityToPersonalityList( INT8 bPersonlity )
// increment attitude list counter
iLastElementInPersonalityList++;
}
return;
}
void CreatePlayerPersonality( void )
@@ -515,8 +452,6 @@ void CreatePlayerPersonality( void )
// DELETED UNUSED PART OF THE CODE - SANDRO
iPersonality = iChosenDisabilityTrait();
return;
}
void CreatePlayersPersonalitySkillsAndAttitude( void )
@@ -531,14 +466,10 @@ void CreatePlayersPersonalitySkillsAndAttitude( void )
// attitude
CreatePlayerAttitude( );
return;
}
void ResetSkillsAttributesAndPersonality( void )
{
// reset count of skills attributes and personality
iLastElementInPersonalityList = 0;
@@ -546,10 +477,8 @@ void ResetSkillsAttributesAndPersonality( void )
iLastElementInSkillsList = 0;
iLastElementInAttitudeList = 0;
}
void ResetIncrementCharacterAttributes( void )
{
// this resets any increments due to character generation
@@ -567,7 +496,6 @@ void ResetIncrementCharacterAttributes( void )
iAddExplosives = 0;
iAddMedical = 0;
iAddMechanical = 0;
}
void SelectMercFace( void )
-2
View File
@@ -7,13 +7,11 @@
void AddAnAttitudeToAttitudeList( INT8 bAttitude );
void CreatePlayerAttitude( void );
BOOLEAN DoesCharacterHaveAnAttitude( void );
void CreateACharacterFromPlayerEnteredStats( void );
void CreatePlayerSkills( void );
void CreatePlayersPersonalitySkillsAndAttitude( void );
void AddAPersonalityToPersonalityList( INT8 bPersonlity );
void CreatePlayerPersonality( void );
BOOLEAN DoesCharacterHaveAPersoanlity( void );
void AddSkillToSkillList( INT8 bSkill );
void ResetSkillsAttributesAndPersonality( void );
void ResetIncrementCharacterAttributes( void );
+7
View File
@@ -1535,6 +1535,13 @@ BOOLEAN LoadImpCharacter( STR nickName )
DoLapTopMessageBox( MSG_BOX_IMP_STYLE, pImpPopUpStrings[ 7 ], LAPTOP_SCREEN, MSG_BOX_FLAG_OK, NULL);
return FALSE;
}
/// Flugente: until the introduction of a separate variable for the voiceset, the voice was identical with the slot
if ( guiCurrentSaveGameVersion < SEPARATE_VOICESETS )
{
gMercProfiles[iProfileId].usVoiceIndex = iProfileId;
}
guiCurrentSaveGameVersion = SAVE_GAME_VERSION;
// close file
+13
View File
@@ -51,6 +51,19 @@ typedef struct
extern IMP_VALUES gIMPValues[NUM_PROFILES];
// Flugente: voicesets are no longer tied to a slot
typedef struct
{
CHAR16 szVoiceSetName[20];
UINT16 voiceset;
BOOLEAN bSex;
BOOLEAN exists; // set upon reading the xml: this voice exists
} IMP_VOICESET;
#define NUM_IMP_VOICESETS 100
extern IMP_VOICESET gIMPVoice[NUM_IMP_VOICESETS];
BOOLEAN AddCharacterToPlayersTeam( void );
BOOLEAN LoadImpCharacter( STR fileName );
void WriteOutCurrentImpCharacter( INT32 iProfileId );
-2
View File
@@ -51,8 +51,6 @@ UINT32 uiVoiceSound = 0;
// image handle
UINT32 guiCHARACTERPORTRAIT;
extern INT32 iCurrentPortrait;
extern INT32 iCurrentVoice;
// function definitions
void CreateIMPFinishButtons( void );
+7 -63
View File
@@ -85,8 +85,6 @@ BOOLEAN CheckIfFinishedCharacterGeneration( void );
INT32 iCurrentProfileMode = IMP__REGISTRY;
extern INT32 iCurrentVoice;
// Return a count of how many IMP slots there are in total
INT32 CountIMPSlots()
{
@@ -269,11 +267,9 @@ BOOLEAN IsIMPSlotFree(INT32 iIMPId)
void EnterIMPMainPage( void )
{
// turn off review mode
fReviewStats = FALSE;
// create buttons
CreateIMPMainPageButtons( );
@@ -288,8 +284,6 @@ void EnterIMPMainPage( void )
// entry into IMP about us page
RenderIMPMainPage( );
return;
}
@@ -300,8 +294,6 @@ void ExitIMPMainPage( void )
// delete Buttons
DeleteIMPMainPageButtons( );
DestoryMouseRegionsForIMPMainPageBasedOnCharGenStatus( );
return;
}
@@ -316,8 +308,6 @@ void RenderIMPMainPage( void )
//RenderIMPSymbol( 106, 1 );
// indent
RenderMainIndentFrame( 164, 74 );
return;
}
@@ -331,7 +321,6 @@ void HandleIMPMainPage( void )
}
// shade out buttons that should be shaded/unselectable
//ShadeUnSelectableButtons( );
return;
}
//
@@ -340,12 +329,10 @@ void HandleIMPMainPage( void )
void CreateIMPMainPageButtons( void )
{
CHAR16 sString[ 128 ];
// the back button button
giIMPMainPageButtonImage[0]= LoadButtonImage( "LAPTOP\\button_3.sti" ,-1,0,-1,1,-1 );
/* giIMPMainPageButton[0] = QuickCreateButton( giIMPMainPageButtonImage[0], LAPTOP_SCREEN_UL_X + 10 , LAPTOP_SCREEN_WEB_UL_Y + ( 360 ),
BUTTON_TOGGLE, MSYS_PRIORITY_HIGHEST - 1,
BtnGenericMouseMoveButtonCallback, (GUI_CALLBACK)BtnIMPMainPageBackCallback);
@@ -485,11 +472,7 @@ void CreateIMPMainPageButtons( void )
{
SpecifyButtonIcon( giIMPMainPageButton[5], guiSMALLSILHOUETTE, 0, 33, 23, FALSE );
}
SetButtonCursor(giIMPMainPageButton[ 0 ], CURSOR_WWW);
SetButtonCursor(giIMPMainPageButton[ 1 ], CURSOR_WWW);
SetButtonCursor(giIMPMainPageButton[ 2 ], CURSOR_WWW);
@@ -507,7 +490,6 @@ void CreateIMPMainPageButtons( void )
SpecifyButtonTextWrappedWidth( giIMPMainPageButton[ 3 ], MAIN_PAGE_BUTTON_TEXT_WIDTH);
SpecifyButtonTextWrappedWidth( giIMPMainPageButton[ 4 ], MAIN_PAGE_BUTTON_TEXT_WIDTH);
SpecifyButtonTextWrappedWidth( giIMPMainPageButton[ 5 ], MAIN_PAGE_BUTTON_TEXT_WIDTH);
return;
}
@@ -538,9 +520,6 @@ void DeleteIMPMainPageButtons( void )
// begin voice button
RemoveButton(giIMPMainPageButton[5] );
UnloadButtonImage(giIMPMainPageButtonImage[5] );
return;
}
void BtnIMPMainPageBackCallback(GUI_BUTTON *btn,INT32 reason)
@@ -570,10 +549,8 @@ void BtnIMPMainPageBackCallback(GUI_BUTTON *btn,INT32 reason)
void BtnIMPMainPageBeginCallback(GUI_BUTTON *btn,INT32 reason)
{
// btn callback for Main Page Begin Profiling
if (!(btn->uiFlags & BUTTON_ENABLED))
return;
@@ -666,9 +643,7 @@ void BtnIMPMainPageAttributesCallback(GUI_BUTTON *btn,INT32 reason)
btn->uiFlags&=~(BUTTON_CLICKED_ON);
return;
}
if(reason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
{
btn->uiFlags|=(BUTTON_CLICKED_ON);
@@ -697,9 +672,7 @@ void BtnIMPMainPagePortraitCallback(GUI_BUTTON *btn,INT32 reason)
btn->uiFlags&=~(BUTTON_CLICKED_ON);
return;
}
if(reason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
{
btn->uiFlags|=(BUTTON_CLICKED_ON);
@@ -715,10 +688,8 @@ void BtnIMPMainPagePortraitCallback(GUI_BUTTON *btn,INT32 reason)
}
}
void BtnIMPMainPageVoiceCallback(GUI_BUTTON *btn,INT32 reason)
{
// btn callback for Main Page Begin Profiling
if (!(btn->uiFlags & BUTTON_ENABLED))
@@ -729,9 +700,7 @@ void BtnIMPMainPageVoiceCallback(GUI_BUTTON *btn,INT32 reason)
btn->uiFlags&=~(BUTTON_CLICKED_ON);
return;
}
if(reason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
{
btn->uiFlags|=(BUTTON_CLICKED_ON);
@@ -749,7 +718,6 @@ void BtnIMPMainPageVoiceCallback(GUI_BUTTON *btn,INT32 reason)
}
}
void NextProfilingMode( void )
{
// this function will change to mode the player is in for profiling
@@ -757,8 +725,6 @@ void NextProfilingMode( void )
// if less than done
if(iCurrentProfileMode < IMP__VOICE)
iCurrentProfileMode++;
return;
}
BOOLEAN CheckIfFinishedCharacterGeneration( void )
@@ -792,7 +758,6 @@ void ShadeUnSelectableButtons( void )
}
fMarkButtonsDirtyFlag = FALSE;
return;
}
@@ -936,22 +901,12 @@ void CreateMouseRegionsForIMPMainPageBasedOnCharGenStatus( void )
// mask for voice page button
MSYS_DefineRegion( &pIMPMainPageMouseRegions[ 3 ],LAPTOP_SCREEN_UL_X + 373 , LAPTOP_SCREEN_WEB_UL_Y + ( 245 ), LAPTOP_SCREEN_UL_X + 373 + 115 , LAPTOP_SCREEN_WEB_UL_Y + ( 245 ) + 93 , MSYS_PRIORITY_HIGH+5,
CURSOR_WWW, MSYS_NO_CALLBACK, IMPMainPageNotSelectableBtnCallback );
return;
}
void DestoryMouseRegionsForIMPMainPageBasedOnCharGenStatus( void )
{
// will destroy button masks for the char gen pages
MSYS_RemoveRegion( &pIMPMainPageMouseRegions[ 0 ]);
MSYS_RemoveRegion( &pIMPMainPageMouseRegions[ 1 ]);
@@ -959,15 +914,10 @@ void DestoryMouseRegionsForIMPMainPageBasedOnCharGenStatus( void )
MSYS_RemoveRegion( &pIMPMainPageMouseRegions[ 2 ]);
MSYS_RemoveRegion( &pIMPMainPageMouseRegions[ 3 ]);
return;
}
void IMPMainPageNotSelectableBtnCallback(MOUSE_REGION * pRegion, INT32 iReason )
{
if (iReason & MSYS_CALLBACK_REASON_INIT)
{
@@ -978,8 +928,6 @@ void IMPMainPageNotSelectableBtnCallback(MOUSE_REGION * pRegion, INT32 iReason )
{
DoLapTopMessageBox( MSG_BOX_IMP_STYLE, pImpPopUpStrings[ 4 ], LAPTOP_SCREEN, MSG_BOX_FLAG_OK, BeginMessageBoxCallBack);
}
return;
}
// WDS: Allow flexible numbers of IMPs of each sex
@@ -1007,7 +955,6 @@ INT32 CountFilledIMPSlots( INT8 iSex )
return iCount;
}
INT32 CountEmptyIMPSlots( INT8 iSex )
{
INT32 i;
@@ -1161,8 +1108,6 @@ BOOLEAN IMP_CanWeDisplayAttributeGraph( )
}
}
BOOLEAN IMP_CanWeDisplaySpecialtiesGraph( )
{
if( iCurrentProfileMode == IMP__ATTRIBUTES ||
@@ -1176,7 +1121,6 @@ BOOLEAN IMP_CanWeDisplaySpecialtiesGraph( )
}
}
BOOLEAN IMP_CanWeDisplayVoiceGraph( )
{
if( iCurrentProfileMode == IMP__ATTRIBUTES ||
+49 -106
View File
@@ -19,20 +19,17 @@
#include "soldier profile type.h"
#include "GameSettings.h"
#include "LaptopSave.h"
#include "IMP Confirm.h"
#endif
INT32 iCurrentVoice = 0;
UINT32 iSelectedIMPVoiceSet = 0;
UINT32 uiVocVoiceSound = 0;
// buttons needed for the IMP Voices screen
INT32 giIMPVoicesButton[ 3 ];
INT32 giIMPVoicesButtonImage[ 3 ];
// hacks to be removeed later
BOOLEAN fVoiceAVisited = FALSE, fVoiceBVisited = FALSE, fVoiceCVisited = FALSE;
// redraw protrait screen
BOOLEAN fReDrawVoicesScreenFlag = FALSE;
@@ -57,20 +54,17 @@ void IMPPortraitRegionButtonCallback(MOUSE_REGION * pRegion, INT32 iReason );
void EnterIMPVoices( void )
{
fVoiceAVisited = FALSE;
fVoiceBVisited = FALSE;
fVoiceCVisited = FALSE;
// Set the initial voice
if (fCharacterIsMale == TRUE)
for ( int i = 0; i < NUM_IMP_VOICESETS; ++i )
{
iCurrentVoice = GetFirstFreeSlot(MALE);
// MALE is 0, FEMALE is 1, thus the negation
if ( gIMPVoice[i].exists && !fCharacterIsMale == gIMPVoice[i].bSex )
{
iCurrentVoice = i;
break;
}
}
else
{
iCurrentVoice = GetFirstFreeSlot(FEMALE);
}
// create buttons
CreateIMPVoicesButtons( );
@@ -82,15 +76,10 @@ void EnterIMPVoices( void )
// play voice once
uiVocVoiceSound = PlayVoice( );
return;
}
void RenderIMPVoices( void )
{
// render background
RenderProfileBackGround( );
@@ -108,11 +97,8 @@ void RenderIMPVoices( void )
// text
PrintImpText( );
return;
}
void ExitIMPVoices( void )
{
// destroy buttons for IMP Voices page
@@ -120,96 +106,68 @@ void ExitIMPVoices( void )
// destroy mouse regions for this screen
DestroyIMPVoiceMouseRegions( );
return;
}
void HandleIMPVoices( void )
{
// do we need to re write screen
if ( fReDrawVoicesScreenFlag == TRUE )
{
RenderIMPVoices( );
RenderIMPVoices( );
// reset redraw flag
fReDrawVoicesScreenFlag = FALSE;
}
return;
}
// WDS: Allow flexible numbers of IMPs of each sex
// Ensure the voice is within the valid range
void FixVoiceRange()
void IncrementVoice()
{
if (fCharacterIsMale == TRUE)
++iCurrentVoice;
for ( int i = iCurrentVoice; i < NUM_IMP_VOICESETS; ++i )
{
if (iCurrentVoice > GetLastMaleSlot())
iCurrentVoice = GetFirstMaleSlot();
else if (iCurrentVoice < GetFirstMaleSlot())
iCurrentVoice = GetLastMaleSlot();
}
else
{
if (iCurrentVoice > GetLastFemaleSlot())
iCurrentVoice = GetFirstFemaleSlot();
else if (iCurrentVoice < GetFirstFemaleSlot())
iCurrentVoice = GetLastFemaleSlot();
}
}
void IncrementVoice( void )
{
INT32 iIMPIndex = -1;
INT32 i;
iCurrentVoice++;
FixVoiceRange();
// Just to be safe (so we use no endless loop)
for (i = 0; i < CountIMPSlots(); i++)
{
if (IsIMPSlotFree(gGameExternalOptions.iaIMPSlots[iCurrentVoice]) == TRUE)
if ( gIMPVoice[i].exists && !fCharacterIsMale == gIMPVoice[i].bSex )
{
// This is a free imp index
iIMPIndex = gGameExternalOptions.iaIMPSlots[iCurrentVoice];
break;
iCurrentVoice = i;
return;
}
}
iCurrentVoice++;
FixVoiceRange();
// still here? Start from the beginning then
for ( int i = 0; i < NUM_IMP_VOICESETS; ++i )
{
if ( gIMPVoice[i].exists && !fCharacterIsMale == gIMPVoice[i].bSex )
{
iCurrentVoice = i;
return;
}
}
}
void DecrementVoice( void )
{
INT32 iIMPIndex = -1;
INT32 i;
--iCurrentVoice;
iCurrentVoice--;
FixVoiceRange();
// Just to be safe (so we use no endless loop)
for (i = 0; i < CountIMPSlots(); i++)
for ( int i = iCurrentVoice; i > 0; --i )
{
if (IsIMPSlotFree(gGameExternalOptions.iaIMPSlots[iCurrentVoice]) == TRUE)
if ( gIMPVoice[i].exists && !fCharacterIsMale == gIMPVoice[i].bSex )
{
// This is the free imp index
iIMPIndex = gGameExternalOptions.iaIMPSlots[iCurrentVoice];
break;
iCurrentVoice = i;
return;
}
}
iCurrentVoice--;
FixVoiceRange();
// still here? Start from the beginning then
for ( int i = NUM_IMP_VOICESETS - 1; i > 0; --i )
{
if ( gIMPVoice[i].exists && !fCharacterIsMale == gIMPVoice[i].bSex )
{
iCurrentVoice = i;
return;
}
}
}
void CreateIMPVoicesButtons( void )
{
// will create buttons need for the IMP Voices screen
@@ -226,8 +184,7 @@ void CreateIMPVoicesButtons( void )
TEXT_CJUSTIFIED,
LAPTOP_SCREEN_UL_X + ( 343 ), LAPTOP_SCREEN_WEB_UL_Y + ( 205 ),BUTTON_TOGGLE, MSYS_PRIORITY_HIGH,
BtnGenericMouseMoveButtonCallback, (GUI_CALLBACK)BtnIMPVoicesNextCallback);
// previous button
giIMPVoicesButtonImage[ 1 ]= LoadButtonImage( "LAPTOP\\voicearrows.sti" ,-1,0,-1,2,-1 );
/* giIMPVoicesButton[ 1 ] = QuickCreateButton( giIMPVoicesButtonImage[ 1 ], LAPTOP_SCREEN_UL_X + ( 18 ), LAPTOP_SCREEN_WEB_UL_Y + ( 254 ),
@@ -240,8 +197,7 @@ void CreateIMPVoicesButtons( void )
TEXT_CJUSTIFIED,
LAPTOP_SCREEN_UL_X + ( 93), LAPTOP_SCREEN_WEB_UL_Y + ( 205 ), BUTTON_TOGGLE, MSYS_PRIORITY_HIGH,
BtnGenericMouseMoveButtonCallback, (GUI_CALLBACK)BtnIMPVoicesPreviousCallback);
// done button
giIMPVoicesButtonImage[ 2 ]= LoadButtonImage( "LAPTOP\\button_5.sti" ,-1,0,-1,1,-1 );
/* giIMPVoicesButton[ 2 ] = QuickCreateButton( giIMPVoicesButtonImage[ 1 ], LAPTOP_SCREEN_UL_X + ( 349 ), LAPTOP_SCREEN_WEB_UL_Y + ( 220 ),
@@ -254,17 +210,13 @@ void CreateIMPVoicesButtons( void )
TEXT_CJUSTIFIED,
LAPTOP_SCREEN_UL_X + ( 187 ), LAPTOP_SCREEN_WEB_UL_Y + ( 330 ), BUTTON_TOGGLE, MSYS_PRIORITY_HIGH,
BtnGenericMouseMoveButtonCallback, (GUI_CALLBACK)BtnIMPVoicesDoneCallback);
SetButtonCursor(giIMPVoicesButton[0], CURSOR_WWW);
SetButtonCursor(giIMPVoicesButton[1], CURSOR_WWW);
SetButtonCursor(giIMPVoicesButton[2], CURSOR_WWW);
}
void DestroyIMPVoicesButtons( void )
{
// will destroy buttons created for IMP Voices screen
@@ -285,7 +237,6 @@ void DestroyIMPVoicesButtons( void )
void BtnIMPVoicesNextCallback( GUI_BUTTON *btn, INT32 reason )
{
// btn callback for IMP attrbite begin button
if ( !(btn->uiFlags & BUTTON_ENABLED) )
return;
@@ -320,7 +271,6 @@ void BtnIMPVoicesNextCallback( GUI_BUTTON *btn, INT32 reason )
void BtnIMPVoicesPreviousCallback( GUI_BUTTON *btn, INT32 reason )
{
// btn callback for IMP attrbite begin button
if ( !(btn->uiFlags & BUTTON_ENABLED) )
return;
@@ -355,7 +305,6 @@ void BtnIMPVoicesPreviousCallback( GUI_BUTTON *btn, INT32 reason )
void BtnIMPVoicesDoneCallback( GUI_BUTTON *btn, INT32 reason )
{
// btn callback for IMP attrbite begin button
if ( !(btn->uiFlags & BUTTON_ENABLED) )
return;
@@ -372,11 +321,8 @@ void BtnIMPVoicesDoneCallback( GUI_BUTTON *btn, INT32 reason )
// Changed to continue to color choosing - SANDRO
iCurrentImpPage = IMP_COLOR_CHOICE_PAGE;
// Following part removed
// set voice id, to grab character slot
// WDS: Allow flexible numbers of IMPs of each sex
LaptopSaveInfo.iIMPIndex = gGameExternalOptions.iaIMPSlots[iCurrentVoice];
iSelectedIMPVoiceSet = gIMPVoice[iCurrentVoice].voiceset;
// set button up image pending
fButtonPendingFlag = TRUE;
@@ -400,7 +346,7 @@ UINT32 PlayVoice( void )
{
CHAR8 zFileName[164];
INT32 iSlot = gGameExternalOptions.iaIMPSlots[iCurrentVoice];
UINT16 iSlot = gIMPVoice[iCurrentVoice].voiceset;
Assert( (iSlot >= 0) && (iSlot <= 999) );
sprintf( zFileName, "Speech\\%03d_001.ogg", iSlot );
@@ -412,7 +358,6 @@ UINT32 PlayVoice( void )
return(PlayJA2SampleFromFile( zFileName, RATE_11025, MIDVOLUME, 1, MIDDLEPAN ));
}
void CreateIMPVoiceMouseRegions( void )
{
// will create mouse regions needed for the IMP voices page
@@ -428,7 +373,6 @@ void DestroyIMPVoiceMouseRegions( void )
MSYS_RemoveRegion( &gVoicePortraitRegion );
}
void IMPPortraitRegionButtonCallback( MOUSE_REGION * pRegion, INT32 iReason )
{
// callback handler for imp portrait region button events
@@ -446,14 +390,13 @@ void IMPPortraitRegionButtonCallback( MOUSE_REGION * pRegion, INT32 iReason )
}
}
void RenderVoiceIndex( void )
{
CHAR16 sString[32];
CHAR16 sString[100];
INT16 sX, sY;
// render the voice index value on the the blank portrait
swprintf( sString, L"%s %d", pIMPVoicesStrings[0], GetVoiceCountFromVoiceSlot( iCurrentVoice ) );
swprintf( sString, L"%s", gIMPVoice[iCurrentVoice].szVoiceSetName );
FindFontCenterCoordinates( 290 + LAPTOP_UL_X, 0, 100, 0, sString, FONT12ARIAL, &sX, &sY );
+2
View File
@@ -7,4 +7,6 @@ void ExitIMPVoices( void );
void HandleIMPVoices( void );
UINT32 PlayVoice( void );
extern UINT32 iSelectedIMPVoiceSet;
#endif
+4
View File
@@ -1072,6 +1072,10 @@
RelativePath=".\XML_IMPPortraits.cpp"
>
</File>
<File
RelativePath=".\XML_IMPVoices.cpp"
>
</File>
<File
RelativePath=".\XML_OldAIMArchive.cpp"
>
+4
View File
@@ -1074,6 +1074,10 @@
RelativePath=".\XML_IMPPortraits.cpp"
>
</File>
<File
RelativePath=".\XML_IMPVoices.cpp"
>
</File>
<File
RelativePath=".\XML_OldAIMArchive.cpp"
>
+2 -1
View File
@@ -208,7 +208,8 @@
<ClCompile Include="XML_EmailMercLevelUp.cpp" />
<ClCompile Include="XML_History.cpp" />
<ClCompile Include="XML_IMPPortraits.cpp" />
<ClCompile Include="XML_OldAIMArchive.cpp" />
<ClCompile Include="XML_IMPVoices.cpp" />
<ClCompile Include="XML_OldAIMArchive.cpp" />
<ClCompile Include="XML_ShippingDestinations.cpp" />
</ItemGroup>
<PropertyGroup Label="Globals">
+3
View File
@@ -499,6 +499,9 @@
</ClCompile>
<ClCompile Include="XML_IMPPortraits.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="XML_IMPVoices.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="XML_AIMAvailability.cpp">
<Filter>Source Files</Filter>
+1
View File
@@ -208,6 +208,7 @@
<ClCompile Include="XML_EmailMercLevelUp.cpp" />
<ClCompile Include="XML_History.cpp" />
<ClCompile Include="XML_IMPPortraits.cpp" />
<ClCompile Include="XML_IMPVoices.cpp" />
<ClCompile Include="XML_OldAIMArchive.cpp" />
<ClCompile Include="XML_ShippingDestinations.cpp" />
</ItemGroup>
+3
View File
@@ -566,5 +566,8 @@
<ClCompile Include="MilitiaWebsite.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="XML_IMPVoices.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
+174
View File
@@ -0,0 +1,174 @@
#ifdef PRECOMPILEDHEADERS
#include "Tactical All.h"
#else
#include "sgp.h"
#include "Debug Control.h"
#include "expat.h"
#include "XML.h"
#include "IMP Confirm.h"
#endif
struct
{
PARSE_STAGE curElement;
CHAR8 szCharData[MAX_CHAR_DATA_LENGTH + 1];
IMP_VOICESET curIMPVoice;
IMP_VOICESET* curArray;
UINT32 maxArraySize;
UINT32 curIndex;
UINT32 currentDepth;
UINT32 maxReadDepth;
}
typedef impVoiceParseData;
IMP_VOICESET gIMPVoice[NUM_IMP_VOICESETS];
static void XMLCALL
impVoicesStartElementHandle( void *userData, const XML_Char *name, const XML_Char **atts )
{
impVoiceParseData * pData = (impVoiceParseData *)userData;
if ( pData->currentDepth <= pData->maxReadDepth ) //are we reading this element?
{
if ( strcmp( name, "IMPVOICELIST" ) == 0 && pData->curElement == ELEMENT_NONE )
{
pData->curElement = ELEMENT_LIST;
pData->maxReadDepth++; //we are not skipping this element
}
else if ( strcmp( name, "VOICE" ) == 0 && pData->curElement == ELEMENT_LIST )
{
pData->curElement = ELEMENT;
pData->maxReadDepth++; //we are not skipping this element
}
else if ( pData->curElement == ELEMENT &&
(strcmp( name, "szVoiceSetName" ) == 0 ||
strcmp( name, "voiceset" ) == 0 ||
strcmp( name, "bSex" ) == 0 ) )
{
pData->curElement = ELEMENT_PROPERTY;
pData->maxReadDepth++; //we are not skipping this element
}
pData->szCharData[0] = '\0';
}
pData->currentDepth++;
}
static void XMLCALL
impVoicesCharacterDataHandle( void *userData, const XML_Char *str, int len )
{
impVoiceParseData * pData = (impVoiceParseData *)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
impVoicesEndElementHandle( void *userData, const XML_Char *name )
{
impVoiceParseData * pData = (impVoiceParseData *)userData;
if ( pData->currentDepth <= pData->maxReadDepth )
{
if ( strcmp( name, "IMPVOICELIST" ) == 0 )
{
pData->curElement = ELEMENT_NONE;
}
else if ( strcmp( name, "VOICE" ) == 0 )
{
pData->curElement = ELEMENT_LIST;
wcscpy( gIMPVoice[pData->curIndex].szVoiceSetName, pData->curIMPVoice.szVoiceSetName );
gIMPVoice[pData->curIndex].voiceset = pData->curIMPVoice.voiceset;
gIMPVoice[pData->curIndex].bSex = pData->curIMPVoice.bSex;
gIMPVoice[pData->curIndex].exists = TRUE;
++pData->curIndex;
}
else if ( strcmp( name, "szVoiceSetName" ) == 0 )
{
pData->curElement = ELEMENT;
MultiByteToWideChar( CP_UTF8, 0, pData->szCharData, -1, pData->curIMPVoice.szVoiceSetName, sizeof(pData->curIMPVoice.szVoiceSetName) / sizeof(pData->curIMPVoice.szVoiceSetName[0]) );
pData->curIMPVoice.szVoiceSetName[sizeof(pData->curIMPVoice.szVoiceSetName) / sizeof(pData->curIMPVoice.szVoiceSetName[0]) - 1] = '\0';
}
else if ( strcmp( name, "voiceset" ) == 0 )
{
pData->curElement = ELEMENT;
pData->curIMPVoice.voiceset = (UINT16)atol( pData->szCharData );
}
else if ( strcmp( name, "bSex" ) == 0 )
{
pData->curElement = ELEMENT;
pData->curIMPVoice.bSex = (BOOLEAN)atol( pData->szCharData );
}
pData->maxReadDepth--;
}
pData->currentDepth--;
}
BOOLEAN ReadInIMPVoices( STR fileName )
{
HWFILE hFile;
UINT32 uiBytesRead;
UINT32 uiFSize;
CHAR8 * lpcBuffer;
XML_Parser parser = XML_ParserCreate( NULL );
impVoiceParseData pData;
pData.curIndex = 0;
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "Loading IMPVoices.xml" );
// Open file
hFile = FileOpen( fileName, 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, impVoicesStartElementHandle, impVoicesEndElementHandle );
XML_SetCharacterDataHandler( parser, impVoicesCharacterDataHandle );
memset( &pData, 0, sizeof(pData) );
XML_SetUserData( parser, &pData );
if ( !XML_Parse( parser, lpcBuffer, uiFSize, TRUE ) )
{
CHAR8 errorBuf[511];
sprintf( errorBuf, "XML Parser Error in IMPVoices.xml: %s at line %d", XML_ErrorString( XML_GetErrorCode( parser ) ), XML_GetCurrentLineNumber( parser ) );
LiveMessage( errorBuf );
MemFree( lpcBuffer );
return FALSE;
}
MemFree( lpcBuffer );
XML_ParserFree( parser );
return(TRUE);
}