// displays the mission objectives in the game resource void ListObjectives(void) { C_ASW_Game_Resource *pGameResource = ASWGameResource(); if ( !pGameResource ) return; for (int i=0;i<12;i++) { if ( pGameResource->GetObjective(i) == NULL ) Msg("Objective %d = empty\n", i); } }
void CASWHudObjective::UpdateObjectiveList() { C_ASW_Game_Resource* pGameResource = ASWGameResource(); if (!pGameResource) return; int iCurrent = 0; bool bNeedsLayout = false; for (int i=0; i<ASW_MAX_OBJECTIVES; i++) { C_ASW_Objective* pObjective = pGameResource->GetObjective(i); bool bUpdatedTitle = false; if (pObjective && !pObjective->IsObjectiveDummy() && !pObjective->IsObjectiveHidden()) { if (m_hObjectives[iCurrent].Get() != pObjective || pObjective->NeedsTitleUpdate() || m_bObjectiveTitleEmpty[iCurrent]) { if (m_hObjectives[iCurrent].Get() != pObjective) { m_bObjectiveComplete[iCurrent] = pObjective->IsObjectiveComplete(); if (pObjective->GetObjectiveIconName()[0] != '\0') { m_pObjectiveIcon[iCurrent]->SetImage(pObjective->GetObjectiveIconName()); //Msg("Set objective icon %d to %s\n", iCurrent, pObjective->GetObjectiveIconName()); } if (pObjective->IsObjectiveComplete()) m_pTickBox[iCurrent]->SetImage("swarm/HUD/TickBoxTicked"); else m_pTickBox[iCurrent]->SetImage("swarm/HUD/TickBoxEmpty"); m_hObjectives[iCurrent] = pObjective; } // set the content for this objective const wchar_t *pTitle = pObjective->GetObjectiveTitle(); bUpdatedTitle = true; m_bObjectiveTitleEmpty[iCurrent] = (pTitle[0] == '\0'); m_pObjectiveLabel[iCurrent]->SetText(pTitle); if (m_bPlayMissionCompleteSequence && m_hObjectiveComplete.Get() == pObjective) { m_pObjectiveGlowLabel->SetText(pTitle); //Msg("A) Set glow label to %s\n", pTitle); } // make sure they're visible if (!m_pObjectiveLabel[iCurrent]->IsVisible()) m_pObjectiveLabel[iCurrent]->SetVisible(true); if (pObjective->GetObjectiveIconName()[0] != '\0' && !m_pObjectiveIcon[iCurrent]->IsVisible()) { //Msg("setting objective icon %d visible\n", iCurrent); m_pObjectiveIcon[iCurrent]->SetVisible(true); } else { m_pObjectiveIcon[iCurrent]->SetVisible(false); } if (!m_pTickBox[iCurrent]->IsVisible()) m_pTickBox[iCurrent]->SetVisible(true); bNeedsLayout = true; } // already have this objective in our list, but check if it's become complete if (m_bObjectiveComplete[iCurrent] != pObjective->IsObjectiveComplete()) { //Msg("Objective %d is now complete!\n", iCurrent); m_bObjectiveComplete[iCurrent] = pObjective->IsObjectiveComplete(); if (pObjective->IsObjectiveComplete()) m_pTickBox[iCurrent]->SetImage("swarm/HUD/TickBoxTicked"); else m_pTickBox[iCurrent]->SetImage("swarm/HUD/TickBoxEmpty"); if (ASWGameRules() && ASWGameRules()->GetGameState() == ASW_GS_INGAME)// && !ASWGameRules()->IsTutorialMap() { m_iObjectiveCompleteSequencePos = iCurrent; m_hObjectiveComplete = pObjective; m_bPlayMissionCompleteSequence = true; m_iNumLetters = 0; GetAnimationController()->RunAnimationCommand(m_pCompleteLabel, "Alpha", 255, 0, 0.1f, AnimationController::INTERPOLATOR_LINEAR); GetAnimationController()->RunAnimationCommand(m_pCompleteLabelBD, "Alpha", 255, 0, 0.1f, AnimationController::INTERPOLATOR_LINEAR); GetAnimationController()->RunAnimationCommand(m_pObjectiveGlowLabel, "Alpha", 255, 0, 0.1f, AnimationController::INTERPOLATOR_LINEAR); const wchar_t *pTitle = pObjective->GetObjectiveTitle(); m_pObjectiveGlowLabel->SetText(pTitle); //Msg("1) Set glow label to %s\n", pTitle); } } if ( m_hObjectiveComplete.Get() != NULL && m_hObjectiveComplete.Get() == pObjective ) { if ( iCurrent != m_iObjectiveCompleteSequencePos ) { m_iObjectiveCompleteSequencePos = iCurrent; bNeedsLayout = true; } } iCurrent++; } } if ( m_iNumObjectivesListed != iCurrent) { m_iNumObjectivesListed = iCurrent; bNeedsLayout = true; } for (int i=iCurrent; i<ASW_MAX_OBJECTIVES; i++) { //Msg("Clearing objective slot %d\n", i); m_hObjectives[i] = NULL; if (m_pObjectiveLabel[i]->IsVisible()) m_pObjectiveLabel[i]->SetVisible(false); if (m_pObjectiveIcon[i]->IsVisible()) m_pObjectiveIcon[i]->SetVisible(false); if (m_pTickBox[i]->IsVisible()) m_pTickBox[i]->SetVisible(false); } if ( IsSpectating() != m_bLastSpectating ) { bNeedsLayout = true; } if ( bNeedsLayout ) { LayoutObjectives(); } }