int CASW_Steamstats::GetFavoriteMarineClass( void ) { // Find the marine's class CASW_Marine_Profile *pProfile = MarineProfileList()->GetProfile( GetFavoriteMarine() ); Assert( pProfile ); return pProfile ? pProfile->GetMarineClass() : 0; }
void CNB_Spend_Skill_Points::OnThink() { BaseClass::OnThink(); CASW_Marine_Profile *pProfile = Briefing()->GetMarineProfileByProfileIndex( m_nProfileIndex ); if ( pProfile ) { char imagename[255]; Q_snprintf( imagename, sizeof(imagename), "briefing/face_%s", pProfile->m_PortraitName ); m_pSelectedMarine->SetImage( imagename ); m_pMarineNameLabel->SetText( pProfile->GetShortName() ); m_pBioLabel->SetText( pProfile->m_Bio ); int nMouseOverSkill = -1; for ( int i = 0; i < NUM_SKILL_PANELS; i++ ) { m_pSkillPanel[ i ]->SetSkillDetails( m_nProfileIndex, i, Briefing()->GetProfileSkillPoints( m_nProfileIndex, i ) ); m_pSkillPanel[ i ]->m_bSpendPointsMode = true; if ( m_pSkillPanel[ i ]->IsCursorOver() ) { nMouseOverSkill = i; } } if ( nMouseOverSkill != -1 && MarineSkills() ) { ASW_Skill nSkillIndex = pProfile->GetSkillMapping( nMouseOverSkill ); // translate from skill slot to skill index m_pSkillTitle->SetText( MarineSkills()->GetSkillName( nSkillIndex ) ); m_pSkillDescription->SetText( MarineSkills()->GetSkillDescription( nSkillIndex ) ); } m_pSpareSkillPointsLabel->SetText( VarArgs( "%d", Briefing()->GetProfileSkillPoints( m_nProfileIndex, ASW_SKILL_SLOT_SPARE ) ) ); } }
void CASW_Hotbar_Entry::UpdateImage() { if ( !m_hMarine.Get() ) { ClearImage(); return; } C_ASW_Weapon *pWeapon = m_hMarine->GetASWWeapon( m_iInventoryIndex ); if ( !pWeapon ) { ClearImage(); return; } const CASW_WeaponInfo* pInfo = pWeapon->GetWeaponInfo(); if ( !pInfo || !pInfo->m_bOffhandActivate ) // TODO: Fix for sentry guns { if ( !asw_hotbar_self.GetBool() || m_iHotKeyIndex != -1 ) // allow your own third item to show even if it's not usable { ClearImage(); return; } } m_pWeaponImage->SetVisible( true ); m_pMarineNameLabel->SetVisible( true ); m_pKeybindLabel->SetVisible( true ); m_pQuantityLabel->SetVisible( true ); m_pWeaponImage->SetImage( pInfo->szEquipIcon ); CASW_Marine_Profile *pProfile = m_hMarine->GetMarineProfile(); if ( pProfile ) { m_pMarineNameLabel->SetText( pProfile->GetShortName() ); } const char *pszKey = ""; if ( m_iHotKeyIndex != -1 ) { char szBinding[ 128 ]; Q_snprintf( szBinding, sizeof( szBinding ), "asw_squad_hotbar %d", m_iHotKeyIndex ); pszKey = ASW_FindKeyBoundTo( szBinding ); } else { pszKey = ASW_FindKeyBoundTo( "+grenade1" ); } char szKey[ 12 ]; Q_snprintf( szKey, sizeof(szKey), "%s", pszKey ); Q_strupr( szKey ); m_pKeybindLabel->SetText( szKey ); // TODO: Eventually make this into instructor key style? or a version of that which fits the HUD char szQuantity[ 32 ]; Q_snprintf( szQuantity, sizeof( szQuantity ), "x%d", pWeapon->Clip1() ); m_pQuantityLabel->SetText( szQuantity ); }
int CASW_Game_Resource::GetSlotForSkill( int nProfileIndex, ASW_Skill nSkillIndex ) { if (nProfileIndex < 0 || nProfileIndex > ASW_NUM_MARINE_PROFILES) return -1; CASW_Marine_Profile *pProfile = MarineProfileList()->GetProfile( nProfileIndex ); if ( !pProfile ) return -1; for ( int i = 0; i < ASW_NUM_SKILL_SLOTS - 1; i++ ) { if ( pProfile->GetSkillMapping( i ) == nSkillIndex ) return i; } return -1; }
bool C_ASW_Button_Area::GetUseAction(ASWUseAction &action, C_ASW_Marine *pUser) { action.UseIconRed = 255; action.UseIconGreen = 255; action.UseIconBlue = 255; action.bShowUseKey = true; action.iInventorySlot = -1; if (!HasPower()) { action.iUseIconTexture = GetNoPowerIconTextureID(); TryLocalize( GetNoPowerText(), action.wszText, sizeof( action.wszText ) ); action.UseTarget = this; action.fProgress = GetHackProgress(); action.bShowUseKey = false; return true; } if (IsLocked()) { CASW_Marine_Profile *pProfile = pUser->GetMarineProfile(); if ( m_bAnyoneCanHack || pProfile->CanHack() ) { action.iUseIconTexture = GetHackIconTextureID(); TryLocalize( GetHackIconText(pUser), action.wszText, sizeof( action.wszText ) ); action.UseTarget = this; action.fProgress = GetHackProgress(); } else { action.iUseIconTexture = GetLockedIconTextureID(); TryLocalize( GetLockedIconText(), action.wszText, sizeof( action.wszText ) ); action.UseTarget = this; action.fProgress = GetHackProgress(); } } else { action.iUseIconTexture = GetUseIconTextureID(); TryLocalize( GetUseIconText(), action.wszText, sizeof( action.wszText ) ); action.UseTarget = this; action.fProgress = -1; } return true; }
// lists a few basic details about a marine's profile void ASW_InspectProfile( const CCommand &args ) { int i = atoi( args[1] ); Msg("Marine profile %d\n", i); CASW_Marine_Profile *profile = MarineProfileList()->m_Profiles[i]; if (profile != NULL) { Msg("Name: %s\n", profile->m_ShortName); Msg("Age: %d\n", profile->m_Age); if (profile->GetMarineClass() == MARINE_CLASS_TECH) Msg("Tech\n"); if (profile->GetMarineClass() == MARINE_CLASS_MEDIC) Msg("First Aid\n"); if (profile->GetMarineClass() == MARINE_CLASS_SPECIAL_WEAPONS) Msg("Special Weapons\n"); if (profile->GetMarineClass() == MARINE_CLASS_NCO) Msg("Sapper\n"); } }
void CASW_Briefing::AutoSelectFullSquadForSingleplayer( int nFirstSelectedProfileIndex ) { if ( !MarineProfileList() ) return; CASW_Marine_Profile* pFirstSelectedProfile = MarineProfileList()->GetProfile( nFirstSelectedProfileIndex ); if ( !pFirstSelectedProfile ) return; ASW_Marine_Class nMarineClasses[]= { MARINE_CLASS_NCO, MARINE_CLASS_SPECIAL_WEAPONS, MARINE_CLASS_MEDIC, MARINE_CLASS_TECH }; // select one of each class for ( int i = 0; i < NELEMS( nMarineClasses ); i++ ) { if ( nMarineClasses[ i ] == pFirstSelectedProfile->GetMarineClass() ) continue; CASW_Marine_Profile* pProfile = NULL; for ( int p = 0; p < MarineProfileList()->m_NumProfiles; p++ ) { pProfile = MarineProfileList()->GetProfile( p ); if ( pProfile && pProfile->GetMarineClass() == nMarineClasses[i] ) { break; } } if ( !pProfile ) continue; SelectMarine( 0, pProfile->m_ProfileIndex, -1 ); } }
float CASW_Steamstats::GetFavoriteMarineClassPercent( void ) { int iFav = 0; float fTotal = 0; int iClassCounts[NUM_MARINE_CLASSES] = {0}; for( int i=0; i<m_MarineSelectionCounts.Count(); ++i ) { // Find the marine's class CASW_Marine_Profile *pProfile = MarineProfileList()->GetProfile( i ); Assert( pProfile ); if( !pProfile ) continue; int iProfileClass = pProfile->GetMarineClass(); iClassCounts[iProfileClass] += m_MarineSelectionCounts[i]; fTotal += m_MarineSelectionCounts[i]; if( iClassCounts[iFav] < iClassCounts[iProfileClass] ) iFav = iProfileClass; } return ( fTotal > 0.0f ) ? ( iClassCounts[iFav] / fTotal * 100.0f ) : 0.0f; }
void CNB_Select_Marine_Panel::OnCommand( const char *command ) { if ( !Q_stricmp( command, "BackButton" ) ) { Briefing()->SetChangingWeaponSlot( 0 ); MarkForDeletion(); CLocalPlayerFilter filter; C_BaseEntity::EmitSound( filter, -1, "ASWComputer.MenuBack" ); return; } else if ( !Q_stricmp( command, "AcceptButton" ) ) { CNB_Select_Marine_Entry *pHighlighted = dynamic_cast<CNB_Select_Marine_Entry*>( GetHighlightedEntry() ); if ( pHighlighted ) { int nProfileIndex = pHighlighted->GetProfileIndex(); if ( !Briefing()->IsProfileSelectedBySomeoneElse( nProfileIndex ) ) { Briefing()->SelectMarine( 0, nProfileIndex, m_nPreferredLobbySlot ); // is this the first marine we've selected? if ( Briefing()->IsOfflineGame() && ASWGameResource() && ASWGameResource()->GetNumMarines( NULL ) <= 0 ) { //Briefing()->AutoSelectFullSquadForSingleplayer( nProfileIndex ); } bool bHasPointsToSpend = Briefing()->IsCampaignGame() && !Briefing()->UsingFixedSkillPoints() && ( Briefing()->GetProfileSkillPoints( nProfileIndex, ASW_SKILL_SLOT_SPARE ) > 0 ); if ( bHasPointsToSpend ) { CNB_Main_Panel *pPanel = dynamic_cast<CNB_Main_Panel*>( GetParent() ); if ( pPanel ) { pPanel->SpendSkillPointsOnMarine( nProfileIndex ); } } else { MarkForDeletion(); Briefing()->SetChangingWeaponSlot( 0 ); } CASW_Marine_Profile* pProfile = Briefing()->GetMarineProfileByProfileIndex( nProfileIndex ); if ( pProfile ) { engine->ClientCmd_Unrestricted(VarArgs("exec configloader/chars/%s\n", pProfile->m_PortraitName)); switch (pProfile->GetMarineClass()) { case MARINE_CLASS_NCO: engine->ClientCmd_Unrestricted("exec configloader/chars/Officer\n"); break; case MARINE_CLASS_SPECIAL_WEAPONS: engine->ClientCmd_Unrestricted("exec configloader/chars/SpecialWeapons\n"); break; case MARINE_CLASS_MEDIC: engine->ClientCmd_Unrestricted("exec configloader/chars/Medic\n"); break; case MARINE_CLASS_TECH: engine->ClientCmd_Unrestricted("exec configloader/chars/Tech\n"); break; default: Assert(0); } } } else { CLocalPlayerFilter filter; C_BaseEntity::EmitSound( filter, -1, "ASWComputer.TimeOut" ); } } return; } BaseClass::OnCommand( command ); }
void CNB_Select_Marine_Panel::OnThink() { BaseClass::OnThink(); for ( int i = 0; i < m_Entries.Count(); i++ ) { if ( m_Entries[i]->IsCursorOver() ) { vgui::Panel *pPanel = m_Entries[i]; CNB_Select_Marine_Entry *pCursorOver = dynamic_cast<CNB_Select_Marine_Entry*>( pPanel ); if ( pCursorOver && pCursorOver->m_pPortraitImage->IsCursorOver() ) { SetHighlight( i ); break; } } } bool bShowSpareSkillPoints = false; CNB_Select_Marine_Entry *pHighlighted = dynamic_cast<CNB_Select_Marine_Entry*>( GetHighlightedEntry() ); if ( pHighlighted ) { int nProfileIndex = pHighlighted->GetProfileIndex(); CASW_Marine_Profile *pProfile = Briefing()->GetMarineProfileByProfileIndex( nProfileIndex ); if ( pProfile ) { m_pMarineNameLabel->SetText( pProfile->GetShortName() ); m_pBioLabel->SetText( pProfile->m_Bio ); m_pSkillPanel0->SetSkillDetails( nProfileIndex, 0, Briefing()->GetProfileSkillPoints( nProfileIndex, 0 ) ); m_pSkillPanel1->SetSkillDetails( nProfileIndex, 1, Briefing()->GetProfileSkillPoints( nProfileIndex, 1 ) ); m_pSkillPanel2->SetSkillDetails( nProfileIndex, 2, Briefing()->GetProfileSkillPoints( nProfileIndex, 2 ) ); m_pSkillPanel3->SetSkillDetails( nProfileIndex, 3, Briefing()->GetProfileSkillPoints( nProfileIndex, 3 ) ); m_pSkillPanel4->SetSkillDetails( nProfileIndex, 4, Briefing()->GetProfileSkillPoints( nProfileIndex, 4 ) ); if ( ASWGameRules() && ASWGameRules()->IsCampaignGame() && ASWGameRules()->GetCampaignSave() && !ASWGameRules()->GetCampaignSave()->UsingFixedSkillPoints() ) { int nSkillPoints = Briefing()->GetProfileSkillPoints( nProfileIndex, ASW_SKILL_SLOT_SPARE ); if ( nSkillPoints > 0 ) { wchar_t buffer[128]; char sparebuffer[8]; Q_snprintf(sparebuffer, sizeof(sparebuffer), "%d", nSkillPoints); wchar_t wsparebuffer[8]; g_pVGuiLocalize->ConvertANSIToUnicode(sparebuffer, wsparebuffer, sizeof( wsparebuffer )); g_pVGuiLocalize->ConstructString( buffer, sizeof(buffer), g_pVGuiLocalize->Find("#asw_unspent_points"), 1, wsparebuffer); m_pSkillPointsLabel->SetText( buffer ); bShowSpareSkillPoints = true; } } } m_pAcceptButton->SetEnabled( !Briefing()->IsProfileSelectedBySomeoneElse( nProfileIndex ) ); } else { } m_pSkillPointsLabel->SetVisible( bShowSpareSkillPoints ); }
void CNB_Skill_Panel::OnThink() { BaseClass::OnThink(); if ( !MarineSkills() || !Briefing() ) return; CASW_Marine_Profile *pProfile = Briefing()->GetMarineProfileByProfileIndex( m_nProfileIndex ); if ( !pProfile ) return; int nMaxSkillPoints = MarineSkills()->GetMaxSkillPoints( pProfile->GetSkillMapping( m_nSkillSlot ) ); const char *szImageName = MarineSkills()->GetSkillImage( pProfile->GetSkillMapping( m_nSkillSlot ) ); if ( Q_strcmp( m_szLastSkillImage, szImageName ) ) { Q_snprintf( m_szLastSkillImage, sizeof( m_szLastSkillImage ), "%s", szImageName ); char buffer[ 256 ]; Q_snprintf( buffer, sizeof( buffer ), "vgui/%s", szImageName ); color32 white; white.r = 255; white.g = 255; white.b = 255; white.a = 255; color32 dull; dull.r = 192; dull.g = 192; dull.b = 192; dull.a = 255; m_pSkillButton->SetImage( CBitmapButton::BUTTON_ENABLED, buffer, white ); m_pSkillButton->SetImage( CBitmapButton::BUTTON_DISABLED, buffer, dull ); m_pSkillButton->SetImage( CBitmapButton::BUTTON_PRESSED, buffer, white ); Q_snprintf( buffer, sizeof( buffer ), "vgui/%s_over", szImageName ); m_pSkillButton->SetImage( CBitmapButton::BUTTON_ENABLED_MOUSE_OVER, buffer, white ); } m_pSkillButton->SetEnabled( m_bSpendPointsMode && CanSpendPoint() ); m_pSkillLabel->SetText( MarineSkills()->GetSkillName( pProfile->GetSkillMapping( m_nSkillSlot ) ) ); wchar_t wszPointsBuffer[ 24 ]; _snwprintf( wszPointsBuffer, sizeof( wszPointsBuffer ), L"%d / %d", m_nSkillPoints, nMaxSkillPoints ); m_pSkillNumberLabel->SetText( wszPointsBuffer ); m_pSkillBar->ClearMinMax(); m_pSkillBar->AddMinMax( 0, nMaxSkillPoints ); m_pSkillBar->Init( m_nSkillPoints, m_nSkillPoints, 0.1f, true, false ); if ( IsCursorOver() ) { if (!g_hBriefingTooltip.Get()) { g_hBriefingTooltip = new BriefingTooltip(GetParent(), "MedalsTooltip"); } else if ( g_hBriefingTooltip->GetParent() != GetParent() ) { g_hBriefingTooltip->SetParent( GetParent() ); } if ( g_hBriefingTooltip.Get() && IsFullyVisible() && g_hBriefingTooltip.Get()->GetTooltipPanel() != this ) { int tx, ty, w, h; tx = ty = 0; LocalToScreen(tx, ty); GetSize(w, h); tx += w * 0.5f; ty -= h * 0.01f; g_hBriefingTooltip.Get()->SetTooltip( this, MarineSkills()->GetSkillName( pProfile->GetSkillMapping( m_nSkillSlot ) ), MarineSkills()->GetSkillDescription( pProfile->GetSkillMapping( m_nSkillSlot ) ), tx, ty ); } } }
void asw_marine_skill_f(const CCommand &args) { CASW_Player *pPlayer = ToASW_Player(UTIL_GetCommandClient()); if (!ASWGameRules()) return; if (!pPlayer) return; CASW_Game_Resource* pGameResource = ASWGameResource(); if (!pGameResource) return; CASW_Marine_Profile *pProfile = NULL; CASW_Marine *pMarine = pPlayer->GetMarine(); if (pMarine) { pProfile = pMarine->GetMarineProfile(); } else { // find the first marine info that belongs to us for (int i=0;i<pGameResource->GetMaxMarineResources();i++) { CASW_Marine_Resource *pMR = pGameResource->GetMarineResource(i); if (pMR && pMR->GetCommander() == pPlayer) { pProfile = pMR->GetProfile(); break; } } } if ( !pProfile ) return; if ( args.ArgC() < 2 ) { Msg("Usage: asw_marine_skill [SkillSlot] - reports the number of skill points of the current marine in that skill\n asw_marine_skill [SkillSlot] [x] - sets that skill to the specified number of skill points (0-5)\n"); Msg("SkillSlot goes from 0 to 4 for your skills, slot 5 is spare skill points.\n"); return; } int nSkillSlot = atoi(args[1]); if ( nSkillSlot < 0 || nSkillSlot >= ASW_NUM_SKILL_SLOTS ) { Msg("nSkillSlot out of bounds\n"); return; } if ( args.ArgC() < 3 ) { int iSkillPoints = ASWGameResource()->GetMarineSkill( pProfile->m_ProfileIndex, nSkillSlot ); Msg( "Marine skill[%d] is %s = %d\n", nSkillSlot, SkillToString( pProfile->GetSkillMapping( nSkillSlot ) ), iSkillPoints ); } else { int iNewPoints = atoi(args[2]); ASWGameResource()->SetMarineSkill( pProfile->m_ProfileIndex, nSkillSlot, iNewPoints ); int iSkillPoints = ASWGameResource()->GetMarineSkill( pProfile->m_ProfileIndex, nSkillSlot ); Msg( "Marine skill[%d] is now %s = %d\n", nSkillSlot, SkillToString( pProfile->GetSkillMapping( nSkillSlot ) ), iSkillPoints ); } }