#ifdef PRECOMPILEDHEADERS #include "Laptop All.h" #include "IMP Skill Trait.h" #include "_Ja25Englishtext.h" #else #include "IMP Minor Trait.h" #include "IMP Skill Trait.h" #include "Button System.h" #include "utilities.h" #include "Debug.h" #include "Text.h" #include "Font Control.h" #include "font.h" #include "laptop.h" #include "cursors.h" #include "IMP MainPage.h" #include "IMPVideoObjects.h" #include "_Ja25EnglishText.h" #include "wordwrap.h" #include "CharProfile.h" #include "soldier profile type.h" #include "IMP Compile Character.h" #include "GameSettings.h" #include "personnel.h" // added by Flugente #endif //******************************************************************* // // Local Defines // //******************************************************************* #define IMP_MINOR_TRAIT__TITLE_FONT FONT14ARIAL #define IMP_MINOR_TRAIT__FONT FONT12ARIAL #define IMP_MINOR_TRAIT__COLOR FONT_MCOLOR_WHITE #define IMP_MINOR_TRAIT__LEFT_COLUMN_START_X ( LAPTOP_SCREEN_UL_X + 15 ) #define IMP_MINOR_TRAIT__LEFT_COLUMN_START_Y ( LAPTOP_SCREEN_WEB_UL_Y + 40 ) #define IMP_MINOR_TRAIT__RIGHT_COLUMN_START_X ( IMP_MINOR_TRAIT__LEFT_COLUMN_START_X + 241 ) #define IMP_MINOR_TRAIT__RIGHT_COLUMN_START_Y IMP_MINOR_TRAIT__LEFT_COLUMN_START_Y #define IMP_MINOR_TRAIT__SPACE_BTN_BUTTONS ( 38 + 5 ) #define IMP_MINOR_TRAIT__TRAITS_TO_START_RIGHT_COL 5 #define IMP_MINOR_TRAIT__NONE_BTN_LOC_X ( LAPTOP_SCREEN_UL_X + 136 ) #define IMP_MINOR_TRAIT__NONE_BTN_LOC_Y ( LAPTOP_SCREEN_WEB_UL_Y + 306 ) #define IMP_MINOR_TRAIT__TEXT_OFFSET_X 65 #define IMP_MINOR_TRAIT__TEXT_OFFSET_Y 12 #define IMP_MINOR_TRAIT__TITLE_X LAPTOP_SCREEN_UL_X - 111 #define IMP_MINOR_TRAIT__GREY_BOX_OFFSET_X 5 #define IMP_MINOR_TRAIT__GREY_BOX_OFFSET_Y 7 // Flugente: Due to the unfortunate nature of our enums, they do not match the trait numbers. We thus have to remap them when obtining their description UINT8 gusNewMinorTraitRemap[IMP_SKILL_TRAITS_NEW_NUMBER_MINOR_SKILLS] = { AMBIDEXTROUS_NT, // IMP_SKILL_TRAITS_NEW_AMBIDEXTROUS MELEE_NT, // IMP_SKILL_TRAITS_NEW_MELEE THROWING_NT, // IMP_SKILL_TRAITS_NEW_THROWING NIGHT_OPS_NT, // IMP_SKILL_TRAITS_NEW_NIGHT_OPS STEALTHY_NT, // IMP_SKILL_TRAITS_NEW_STEALTHY ATHLETICS_NT, // IMP_SKILL_TRAITS_NEW_ATHLETICS BODYBUILDING_NT, // IMP_SKILL_TRAITS_NEW_BODYBUILDING DEMOLITIONS_NT, // IMP_SKILL_TRAITS_NEW_DEMOLITIONS TEACHING_NT, // IMP_SKILL_TRAITS_NEW_TEACHING SCOUTING_NT, // IMP_SKILL_TRAITS_NEW_SCOUTING RADIO_OPERATOR_NT, // IMP_SKILL_TRAITS_NEW_RADIO_OPERATOR SURVIVAL_NT, // IMP_SKILL_TRAITS_NEW_SURVIVAL NO_SKILLTRAIT_NT, // IMP_SKILL_TRAITS_NEW_MINOR_NONE }; //******************************************************************* // // Global Variables // //******************************************************************* BOOLEAN gfIMT_Redraw=FALSE; BOOLEAN gfMinorTraitQuestions[ IMP_SKILL_TRAITS_NEW_NUMBER_MINOR_SKILLS ]; // these are the buttons for the questions INT32 giIMPMinorTraitAnswerButton[ IMP_SKILL_TRAITS_NEW_NUMBER_MINOR_SKILLS ]; INT32 giIMPMinorTraitAnswerButtonImage[ IMP_SKILL_TRAITS_NEW_NUMBER_MINOR_SKILLS ]; // this is the Done buttons INT32 giIMPMinorlTraitFinsihButton; INT32 giIMPMinorlTraitFinsihButtonImage; INT8 gbLastSelectedMinorTrait[ NUM_MINOR_TRAITS ]; //image handle UINT32 guiIMT_GreyGoldBox; MOUSE_REGION gMR_MinorTraitHelpTextRegions[IMP_SKILL_TRAITS_NEW_NUMBER_MINOR_SKILLS]; //******************************************************************* // // Function Prototypes // //******************************************************************* void BtnIMPMinorTraitAnswerCallback(GUI_BUTTON *btn,INT32 reason); void BtnIMPMinorTraitFinishCallback(GUI_BUTTON *btn,INT32 reason); void AddIMPMinorTraitButtons(); void HandleMinorTraitButtonStates( ); void HandleIMPMinorTraitAnswers( UINT32 uiSkillPressed ); void IMPMinorTraitDisplaySkills(); BOOLEAN CameBackToMinorTraitPageButNotFinished(); void HandleLastSelectedMinorTrait( INT8 bNewTrait ); INT8 GetLastSelectedMinorTrait( void ); INT8 NumAvailableMinorTraits(); //ppp //******************************************************************* // // Functions // //******************************************************************* void EnterIMPMinorTrait( void ) { UINT8 ubCnt; // UINT32 ubCnt; VOBJECT_DESC VObjectDesc; //add the skill trait buttons AddIMPMinorTraitButtons(); // load the stats graphic and add it VObjectDesc.fCreateFlags=VOBJECT_CREATE_FROMFILE; FilenameForBPP("LAPTOP\\SkillTraitSmallGreyIdent.sti", VObjectDesc.ImageFile); if( !AddVideoObject(&VObjectDesc, &guiIMT_GreyGoldBox ) ) { Assert( 0 ); return; } giIMPMinorlTraitFinsihButtonImage = LoadButtonImage( "LAPTOP\\button_5.sti" ,-1,0,-1,1,-1 ); giIMPMinorlTraitFinsihButton = CreateIconAndTextButton( giIMPMinorlTraitFinsihButtonImage, pImpButtonText[ 24 ], FONT12ARIAL, FONT_WHITE, DEFAULT_SHADOW, FONT_WHITE, DEFAULT_SHADOW, TEXT_CJUSTIFIED, LAPTOP_SCREEN_UL_X + ( 350 ), LAPTOP_SCREEN_WEB_UL_Y + ( 340 ), BUTTON_TOGGLE, MSYS_PRIORITY_HIGH, BtnGenericMouseMoveButtonCallback, (GUI_CALLBACK)BtnIMPMinorTraitFinishCallback ); SetButtonCursor( giIMPMinorlTraitFinsihButton, CURSOR_WWW); //if we are not DONE and are just reviewing if( iCurrentProfileMode != IMP__FINISH ) { for (ubCnt = 0; ubCntuiFlags & BUTTON_ENABLED)) return; if( reason & MSYS_CALLBACK_REASON_LBUTTON_DWN ) { // btn->uiFlags|=(BUTTON_CLICKED_ON); if( NumAvailableMinorTraits() > 0 ) { INT32 iMinorTrait = MSYS_GetBtnUserData( btn, 0 ); HandleIMPMinorTraitAnswers( iMinorTrait ); } else DoLapTopMessageBox( MSG_BOX_IMP_STYLE, pImpPopUpStrings[ 12 ], LAPTOP_SCREEN, MSG_BOX_FLAG_OK, NULL); } } void HandleIMPMinorTraitAnswers( UINT32 uiSkillPressed ) { UINT32 uiCnt; //if we are DONE and are just reviewing if( iCurrentProfileMode == IMP__FINISH ) { return; } //make sure its a valid skill if( uiSkillPressed >= IMP_SKILL_TRAITS_NEW_NUMBER_MINOR_SKILLS ) { Assert( 0 ); return; } //if its allready set if( gfMinorTraitQuestions[ uiSkillPressed ] && uiSkillPressed != IMP_SKILL_TRAITS_NEW_MINOR_NONE ) { gfMinorTraitQuestions[ uiSkillPressed ] = FALSE; BOOLEAN fNoSkillSelected = TRUE; for ( uiCnt=0; uiCnt<(IMP_SKILL_TRAITS_NEW_MINOR_NONE); uiCnt++ ) { if ( gfMinorTraitQuestions[ uiCnt ] == TRUE ) fNoSkillSelected = FALSE; } if ( fNoSkillSelected ) { // select NONE button gfMinorTraitQuestions[ IMP_SKILL_TRAITS_NEW_MINOR_NONE ] = TRUE; } } else { //if we are to reset all the buttons if( CountNumMinorTraitsSelected( FALSE ) >= NumAvailableMinorTraits() ) { // try to remove the last selected minor trait if ( gfMinorTraitQuestions[ GetLastSelectedMinorTrait() ] > 0 ) { gfMinorTraitQuestions[ GetLastSelectedMinorTrait() ] = FALSE; // remove this one from list HandleLastSelectedMinorTrait( -1 ); } // if there is none, remove all for sure else { //loop through all the skill and reset them for( uiCnt=0; uiCntuiFlags |= BUTTON_CLICKED_ON; } else { ButtonList[ giIMPMinorTraitAnswerButton[ uiCnt ] ]->uiFlags &= ~BUTTON_CLICKED_ON; } } } void IMPMinorTraitDisplaySkills() { UINT32 uiCnt; UINT16 usPosX, usPosY; UINT16 usBoxPosX, usBoxPosY; HVOBJECT hImageHandle; //Display the title DrawTextToScreen( gzIMPSkillTraitsTextNewMinor[ IMP_SKILL_TRAITS_NEW_NUMBER_MINOR_SKILLS ], IMP_MINOR_TRAIT__TITLE_X, LAPTOP_TITLE_Y, LAPTOP_TEXT_WIDTH, IMP_MINOR_TRAIT__TITLE_FONT, IMP_MINOR_TRAIT__COLOR, FONT_MCOLOR_BLACK, FALSE, CENTER_JUSTIFIED ); // Stats GetVideoObject(&hImageHandle, guiIMT_GreyGoldBox ); usPosX = IMP_MINOR_TRAIT__LEFT_COLUMN_START_X + IMP_MINOR_TRAIT__TEXT_OFFSET_X; usPosY = IMP_MINOR_TRAIT__LEFT_COLUMN_START_Y + IMP_MINOR_TRAIT__TEXT_OFFSET_Y; for( uiCnt=0; uiCntuiFlags & BUTTON_ENABLED)) return; if( reason & MSYS_CALLBACK_REASON_LBUTTON_DWN ) { btn->uiFlags|=(BUTTON_CLICKED_ON); // Flugente: setting determines whether we see the background page if ( UsingBackGroundSystem() ) { iCurrentImpPage = IMP_BACKGROUND; fButtonPendingFlag = TRUE; } //if we are just reviewing the page else if( iCurrentProfileMode == IMP__FINISH ) { //go back to the done screen iCurrentImpPage = IMP_FINISH; } else { iCurrentImpPage = IMP_MAIN_PAGE; fButtonPendingFlag = TRUE; if( CameBackToMinorTraitPageButNotFinished() ) { } else { //We are finished on this page iCurrentProfileMode = IMP__ATTRIBUTES; } } } } BOOLEAN CameBackToMinorTraitPageButNotFinished() { //if we are in a page that comes after this one if( iCurrentProfileMode == IMP__ATTRIBUTES ) { return( TRUE ); } else { return( FALSE ); } } INT8 CountNumMinorTraitsSelected( BOOLEAN fIncludeNoneSkill ) { UINT32 uiCnt; INT8 iNumberSkills=0; for( uiCnt=0; uiCnt < IMP_SKILL_TRAITS_NEW_NUMBER_MINOR_SKILLS; uiCnt++ ) { if( !fIncludeNoneSkill && uiCnt == IMP_SKILL_TRAITS_NEW_MINOR_NONE ) continue; //if the skill is selected ( ie depressed ) else if( gfMinorTraitQuestions[ uiCnt ] ) { iNumberSkills++; } } return( iNumberSkills ); } INT8 NumAvailableMinorTraits() { INT8 bNumMinorTraits=0; INT8 bNumMajorTraits=0; //Count the number of skills selected bNumMajorTraits = CountNumSkillTraitsSelected( FALSE ); bNumMinorTraits = gSkillTraitValues.ubMaxNumberOfTraitsForIMP - bNumMajorTraits; bNumMinorTraits = max( 0, bNumMinorTraits ); return(bNumMinorTraits); } void AddSelectedMinorTraitsToSkillsList() { UINT32 uiCnt; // if we have somehow reached beyond available traits, try to fix it by removing the last one selected if ( NumAvailableMinorTraits() < CountNumMinorTraitsSelected( FALSE ) ) { if (gfMinorTraitQuestions[ GetLastSelectedMinorTrait() ] == TRUE ) gfMinorTraitQuestions[ GetLastSelectedMinorTrait() ] = FALSE; } // if still something is wrong, remove them all if ( NumAvailableMinorTraits() < CountNumMinorTraitsSelected( FALSE ) ) { for( uiCnt=0; uiCnt=0; iCnt-- ) { if ( gbLastSelectedMinorTrait[ iCnt ] > 0 ) { gbLastSelectedMinorTrait[ iCnt ] = 0; break; } } } else { for( iCnt=0; iCnt=0; iCnt-- ) { if ( gbLastSelectedMinorTrait[ iCnt ] > 0 ) { return ( gbLastSelectedMinorTrait[ iCnt ] ); break; } } return ( 0 ); } UINT8 StrengthRequiredAdjustmentForMinorTraits( INT32 iInitialValue ) { // Only for new trait system if (!gGameOptions.fNewTraitSystem || !gSkillTraitValues.fAllowAttributePrereq) { return 0; } if ( gfMinorTraitQuestions[ IMP_SKILL_TRAITS_NEW_MELEE ] ) { // 60 is minimum, +10 is addition to other preset requirements if( (iInitialValue + 10) < 60 ) { // if less than minimum, add how much we need return ( 60 - iInitialValue ); } else { // otherwise just add 10 on top return ( 10 ); } } return( 0 ); } UINT8 DexterityRequiredAdjustmentForMinorTraits( INT32 iInitialValue ) { // Only for new trait system if (!gGameOptions.fNewTraitSystem || !gSkillTraitValues.fAllowAttributePrereq) { return 0; } if ( gfMinorTraitQuestions[ IMP_SKILL_TRAITS_NEW_AMBIDEXTROUS ] && gfMinorTraitQuestions[ IMP_SKILL_TRAITS_NEW_THROWING ] ) { // 70 is minimum if having both, +20 is addition to other preset requirements if( (iInitialValue + 20) < 70 ) { // if less than minimum, add how much we need return ( 70 - iInitialValue ); } else { // otherwise just add 10 on top return ( 20 ); } } else if ( gfMinorTraitQuestions[ IMP_SKILL_TRAITS_NEW_AMBIDEXTROUS ] ) { // 60 is minimum, +10 is addition to other preset requirements if( (iInitialValue + 10) < 60 ) { // if less than minimum, add how much we need return ( 60 - iInitialValue ); } else { // otherwise just add 10 on top return ( 10 ); } } else if ( gfMinorTraitQuestions[ IMP_SKILL_TRAITS_NEW_THROWING ] ) { // 60 is minimum, +10 is addition to other preset requirements if( (iInitialValue + 10) < 60 ) { // if less than minimum, add how much we need return ( 60 - iInitialValue ); } else { // otherwise just add 10 on top return ( 10 ); } } return( 0 ); } UINT8 AgilityRequiredAdjustmentForMinorTraits( INT32 iInitialValue ) { // Only for new trait system if (!gGameOptions.fNewTraitSystem || !gSkillTraitValues.fAllowAttributePrereq) { return 0; } if ( gfMinorTraitQuestions[ IMP_SKILL_TRAITS_NEW_ATHLETICS ] && gfMinorTraitQuestions[ IMP_SKILL_TRAITS_NEW_STEALTHY ] ) { // 70 is minimum if having both, +20 is addition to other preset requirements if( (iInitialValue + 20) < 70 ) { // if less than minimum, add how much we need return ( 70 - iInitialValue ); } else { // otherwise just add 10 on top return ( 20 ); } } else if ( gfMinorTraitQuestions[ IMP_SKILL_TRAITS_NEW_ATHLETICS ] ) { // 60 is minimum, +10 is addition to other preset requirements if( (iInitialValue + 10) < 60 ) { // if less than minimum, add how much we need return ( 60 - iInitialValue ); } else { // otherwise just add 10 on top return ( 10 ); } } else if ( gfMinorTraitQuestions[ IMP_SKILL_TRAITS_NEW_STEALTHY ] ) { // 60 is minimum, +10 is addition to other preset requirements if( (iInitialValue + 10) < 60 ) { // if less than minimum, add how much we need return ( 60 - iInitialValue ); } else { // otherwise just add 10 on top return ( 10 ); } } return( 0 ); } UINT8 HealthRequiredAdjustmentForMinorTraits( INT32 iInitialValue ) { // Only for new trait system if (!gGameOptions.fNewTraitSystem || !gSkillTraitValues.fAllowAttributePrereq) { return 0; } if ( gfMinorTraitQuestions[ IMP_SKILL_TRAITS_NEW_BODYBUILDING ] ) { // 60 is minimum, +10 is addition to other preset requirements if( (iInitialValue + 10) < 60 ) { // if less than minimum, add how much we need return ( 60 - iInitialValue ); } else { // otherwise just add 10 on top return ( 10 ); } } return( 0 ); } UINT8 WisdomRequiredAdjustmentForMinorTraits( INT32 iInitialValue ) { // Only for new trait system if (!gGameOptions.fNewTraitSystem || !gSkillTraitValues.fAllowAttributePrereq) { return 0; } if ( gfMinorTraitQuestions[ IMP_SKILL_TRAITS_NEW_NIGHT_OPS ] && gfMinorTraitQuestions[ IMP_SKILL_TRAITS_NEW_SCOUTING ] ) { // 70 is minimum if having both, +20 is addition to other preset requirements if( (iInitialValue + 20) < 70 ) { // if less than minimum, add how much we need return ( 70 - iInitialValue ); } else { // otherwise just add 10 on top return ( 20 ); } } else if ( gfMinorTraitQuestions[ IMP_SKILL_TRAITS_NEW_NIGHT_OPS ] ) { // 60 is minimum, +10 is addition to other preset requirements if( (iInitialValue + 10) < 60 ) { // if less than minimum, add how much we need return ( 60 - iInitialValue ); } else { // otherwise just add 10 on top return ( 10 ); } } else if ( gfMinorTraitQuestions[ IMP_SKILL_TRAITS_NEW_SCOUTING ] ) { // 60 is minimum, +10 is addition to other preset requirements if( (iInitialValue + 10) < 60 ) { // if less than minimum, add how much we need return ( 60 - iInitialValue ); } else { // otherwise just add 10 on top return ( 10 ); } } return( 0 ); } UINT8 LeaderShipRequiredAdjustmentForMinorTraits( INT32 iInitialValue ) { // Only for new trait system if (!gGameOptions.fNewTraitSystem || !gSkillTraitValues.fAllowAttributePrereq) { return 0; } if ( gfMinorTraitQuestions[ IMP_SKILL_TRAITS_NEW_TEACHING ] ) { // 60 is minimum, +10 is addition to other preset requirements if( (iInitialValue + 10) < 45 ) { // if less than minimum, add how much we need return ( 45 - iInitialValue ); } else { // otherwise just add 10 on top return ( 10 ); } } return( 0 ); } UINT8 MarksmanshipRequiredAdjustmentForMinorTraits( INT32 iInitialValue ) { // nothing here return( 0 ); } UINT8 MechanicalRequiredAdjustmentForMinorTraits( INT32 iInitialValue ) { // nothing here return( 0 ); } UINT8 MedicalRequiredAdjustmentForMinorTraits( INT32 iInitialValue ) { // nothing here return( 0 ); } UINT8 ExplosivesRequiredAdjustmentForMinorTraits( INT32 iInitialValue ) { // Only for new trait system if (!gGameOptions.fNewTraitSystem || !gSkillTraitValues.fAllowAttributePrereq) { return 0; } if ( gfMinorTraitQuestions[ IMP_SKILL_TRAITS_NEW_DEMOLITIONS ] ) { // 60 is minimum, +10 is addition to other preset requirements if( (iInitialValue + 10) < 45 ) { // if less than minimum, add how much we need return ( 45 - iInitialValue ); } else { // otherwise just add 10 on top return ( 10 ); } } return( 0 ); }