///BEGIN key binding functions void ToggleTraitRangeView(BOOLEAN fOn) { if ( fOn ) { gubDrawModeTrait = TRAIT_DRAW_RANGE; gubDrawMode = COVER_DRAW_OFF; gubDrawModeMine = MINES_DRAW_OFF; } else { gubDrawModeTrait = TRAIT_DRAW_OFF; SetTraitToDisplay( NO_SKILLTRAIT_NT ); SetGridNoForTraitDisplay( NOWHERE ); } //ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Display trait ranges"); DisplayTraitRange(TRUE); }
/////////////////////////////// Artillery Team Selection //////////////////////////////////////////// void ArtilleryTeam::Setup( UINT32 aVal ) { Destroy(); SOLDIERTYPE * pSoldier = NULL; GetSoldier( &pSoldier, gusSelectedSoldier ); if ( pSoldier == NULL ) return; if ( pSoldier->CanUseSkill(SKILLS_RADIO_ARTILLERY) && pSoldier->bSectorZ == 0) { usSector = aVal; SetupPopup("ArtilleryTeam"); POPUP_OPTION *pOption; CHAR16 pStr[300]; // determine sector coordinates INT16 sSectorX = SECTORX(usSector); INT16 sSectorY = SECTORY(usSector); // order artillery from militia swprintf( pStr, pSkillMenuStrings[SKILLMENU_MILITIA] ); pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction<void, UINT32>( &Wrapper_Function_ArtilleryTeam, MILITIA_TEAM ) ); // grey out if no ArtilleryTeam can be called from this sector if ( !IsValidArtilleryOrderSector( sSectorX, sSectorY, pSoldier->bSectorZ, MILITIA_TEAM ) ) { // Set this option off. pOption->setAvail(new popupCallbackFunction<bool,void*>( &Popup_OptionOff, NULL )); } GetPopup()->addOption( *pOption ); // order artillery from our mercs swprintf( pStr, pSkillMenuStrings[SKILLMENU_OTHERSQUADS] ); pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction<void, INT8>( &Wrapper_Function_ArtilleryTeam, pSoldier->bTeam ) ); // grey out if no ArtilleryTeam can be called from this sector if ( !IsValidArtilleryOrderSector( sSectorX, sSectorY, pSoldier->bSectorZ, pSoldier->bTeam ) ) { // Set this option off. pOption->setAvail(new popupCallbackFunction<bool,void*>( &Popup_OptionOff, NULL )); } GetPopup()->addOption( *pOption ); // cancel option swprintf( pStr, pSkillMenuStrings[SKILLMENU_CANCEL] ); pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction<void,UINT32>( &Wrapper_Cancel_ArtilleryTeam, 0 ) ); GetPopup()->addOption( *pOption ); // certain traits have skills whose effects depend on wether someone is near to us (squadleader, commissar). We therefore display our radius of effect while this display is open SetTraitToDisplay(RADIO_OPERATOR_NT); SetGridNoForTraitDisplay(sTraitsMenuTargetGridNo); ToggleTraitRangeView(TRUE); } // same y, different x SetPos(gArtillerySector.GetMaxPosX(), usTraitMenuPosY); }
/////////////////////////////// Artillery Sector Selection //////////////////////////////////////////// void ArtillerySector::Setup( UINT32 aVal ) { Destroy(); SOLDIERTYPE * pSoldier = NULL; GetSoldier( &pSoldier, gusSelectedSoldier ); if ( pSoldier == NULL ) return; if ( pSoldier->CanUseSkill(SKILLS_RADIO_ARTILLERY) ) { SetupPopup("ArtillerySector"); POPUP_OPTION *pOption; CHAR16 pStr[300]; // check wether we can call artillery from the 4 adjacent sectors for (UINT8 i = 0; i < 4; ++i) { INT16 loopX = pSoldier->sSectorX; INT16 loopY = pSoldier->sSectorY; if ( i == 0 ) ++loopY; else if ( i == 1 ) ++loopX; else if ( i == 2 ) --loopY; else if ( i == 3 ) --loopX; if ( loopX < 1 || loopX >= MAP_WORLD_X - 1 || loopY < 1 || loopY >= MAP_WORLD_Y - 1 ) continue; UINT32 sectornr = (UINT32)SECTOR( loopX, loopY ); swprintf( pStr, L"%c%d", loopY + 'A' - 1, loopX ); pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction<void, UINT32>( &Wrapper_Setup_ArtilleryTeam, sectornr ) ); // grey out if no artillery can be called from this sector if ( !IsValidArtilleryOrderSector( loopX, loopY, pSoldier->bSectorZ, pSoldier->bTeam ) && !IsValidArtilleryOrderSector( loopX, loopY, pSoldier->bSectorZ, MILITIA_TEAM ) ) { // Set this option off. pOption->setAvail(new popupCallbackFunction<bool,void*>( &Popup_OptionOff, NULL )); } GetPopup()->addOption( *pOption ); } // cancel option swprintf( pStr, pSkillMenuStrings[SKILLMENU_CANCEL] ); pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction<void,UINT32>( &Wrapper_Cancel_ArtillerySector, 0 ) ); GetPopup()->addOption( *pOption ); // certain traits have skills whose effects depend on wether someone is near to us (squadleader, commissar). We therefore display our radius of effect while this display is open SetTraitToDisplay(RADIO_OPERATOR_NT); SetGridNoForTraitDisplay(sTraitsMenuTargetGridNo); ToggleTraitRangeView(TRUE); } // same y, different x SetPos(gSkillSelection.GetMaxPosX(), usTraitMenuPosY); }
/////////////////////////////// Skill Selection //////////////////////////////////////////// void SkillSelection::Setup( UINT32 aVal ) { Destroy(); SOLDIERTYPE * pSoldier = NULL; GetSoldier( &pSoldier, gusSelectedSoldier ); if ( pSoldier == NULL ) return; if ( HAS_SKILL_TRAIT(pSoldier, aVal) ) { SetupPopup("SkillSelection"); POPUP_OPTION *pOption; CHAR16 pStr[300]; SetTraitToDisplay(aVal); SetGridNoForTraitDisplay(sTraitsMenuTargetGridNo); // this switch isn't really necessary. But dividing the skills into menus for each trait gives a better overview, and looks way better than a huge list switch ( aVal ) { case RADIO_OPERATOR_NT: { for(UINT32 uiCounter = SKILLS_RADIO_FIRST; uiCounter <= SKILLS_RADIO_LAST; ++uiCounter) { swprintf( pStr, pTraitSkillsMenuStrings[uiCounter] ); if ( uiCounter == SKILLS_RADIO_ARTILLERY) pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction<void,UINT32>( &Wrapper_Setup_ArtillerySector, uiCounter ) ); else if ( uiCounter == SKILLS_RADIO_CALLREINFORCEMENTS) pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction<void,UINT32>( &Wrapper_Setup_ReinforcementSector, uiCounter ) ); else pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction<void,UINT32>( &Wrapper_Function_SkillSelection, uiCounter ) ); // if we cannot perform this skill, grey it out if ( !(pSoldier->CanUseSkill(uiCounter, TRUE)) ) { // Set this option off. pOption->setAvail(new popupCallbackFunction<bool,void*>( &Popup_OptionOff, NULL )); } GetPopup()->addOption( *pOption ); } } break; case VARIOUSSKILLS: { for(UINT32 uiCounter = SKILLS_VARIOUS_FIRST; uiCounter <= SKILLS_VARIOUS_LAST; ++uiCounter) { swprintf( pStr, pTraitSkillsMenuStrings[uiCounter] ); pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction<void,UINT32>( &Wrapper_Function_SkillSelection, uiCounter ) ); // if we cannot perform this skill, grey it out if ( !(pSoldier->CanUseSkill(uiCounter, TRUE)) ) { // Set this option off. pOption->setAvail(new popupCallbackFunction<bool,void*>( &Popup_OptionOff, NULL )); } GetPopup()->addOption( *pOption ); } SetTraitToDisplay(VARIOUSSKILLS); SetGridNoForTraitDisplay(sTraitsMenuTargetGridNo); ToggleTraitRangeView(TRUE); } break; default: break; } // cancel option swprintf( pStr, pSkillMenuStrings[SKILLMENU_CANCEL] ); pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction<void,UINT32>( &Wrapper_Cancel_SkillSelection, 0 ) ); GetPopup()->addOption( *pOption ); } // same y, different x SetPos(gTraitSelection.GetMaxPosX(), usTraitMenuPosY); if ( HAS_SKILL_TRAIT(pSoldier, aVal) ) { UINT8 cnt = 0; switch ( aVal ) { case RADIO_OPERATOR_NT: { for(UINT32 uiCounter = SKILLS_RADIO_FIRST; uiCounter <= SKILLS_RADIO_LAST; ++uiCounter) { SetRegionFastHelpText( &(GetPopup()->MenuRegion[cnt++]), pSoldier->PrintSkillDesc(uiCounter) ); } } break; case VARIOUSSKILLS: { for(UINT32 uiCounter = SKILLS_VARIOUS_FIRST; uiCounter <= SKILLS_VARIOUS_LAST; ++uiCounter) { SetRegionFastHelpText( &(GetPopup()->MenuRegion[cnt++]), pSoldier->PrintSkillDesc(uiCounter) ); } } break; } } }