Beispiel #1
0
void SelectMenu::handleShow() {

    menu_manager_->saveBackground();

    // Show the mouse
    g_System.showCursor();

    // Update the time
    updateClock();

    if (g_gameCtrl.agents().squadMember(cur_agent_)) {
        getStatic(txtAgentId_)->setTextFormated("#SELECT_SUBTITLE", g_gameCtrl.agents().squadMember(cur_agent_)->getName());
    } else {
        getStatic(txtAgentId_)->setText("");
    }

    for (int iAgnt=0; iAgnt<AgentManager::MAX_AGENT; iAgnt++) {
        Agent *pAgentFromCryo = g_gameCtrl.agents().agent(iAgnt);
        pTeamLBox_->setSquadLine(g_gameCtrl.agents().getSquadSlotForAgent(pAgentFromCryo), iAgnt);
    }
    showItemList();

    updateAcceptEnabled();
    menu_manager_->resetSinceMouseDown();
}
Beispiel #2
0
/*! 
 * Update the game time display
 */
void SelectMenu::updateClock() {
    char tmp[100];
    g_Session.getTimeAsStr(tmp);
    getStatic(txtTimeId_)->setText(tmp);

    // update money
    getStatic(moneyTxtId_)->setTextFormated("%d", g_Session.getMoney());
}
Beispiel #3
0
void DebriefMenu::handleLeave() {
    // We're leaving to the map menu
    // So at this point the current mission is no more needed
    // as a new one will be selected in the map menu
    g_Session.setMission(NULL);

    getStatic(txtNewWeap1Id_)->setText("");
    getStatic(txtNewWeap2Id_)->setText("");

    g_System.hideCursor();
}
Beispiel #4
0
void BriefMenu::handleShow() {

    menu_manager_->saveBackground();

    // grab mission info
    int cur_miss = g_Session.getSelectedBlock().mis_id;
    Mission *pMission = g_App.missions().loadMission(cur_miss);
    assert(pMission != NULL);
    g_Session.setMission(pMission);

	// Loads mission briefing
	p_briefing_ = g_App.missions().loadBriefing(cur_miss);
    assert(p_briefing_ != NULL);

    start_line_ = 0;
    getOption(prevButId_)->setVisible(false);
    getOption(nextButId_)->setVisible(false);
    update_briefing_text();

    // reset minimap renderer with current mission
    uint8 enh_lvl = g_Session.getSelectedBlock().enhanceLevel;
    MinimapRenderer::EZoom zoom =
        toZoomLevel(enh_lvl);
    
    bool drawEnemies = enh_lvl == p_briefing_->nb_enhts();

    mm_renderer_.init(pMission, zoom, drawEnemies);

    updateClock();

    // Initialize the informations label with current cost
    if (g_Session.getSelectedBlock().infoLevel < p_briefing_->nb_infos()) {
        getStatic(txtInfoId_)->setTextFormated("%d",
            p_briefing_->infoCost(g_Session.getSelectedBlock().infoLevel));
        getOption(infosButId_)->setWidgetEnabled(true);
    } else {
        getStatic(txtInfoId_)->setText("");
        getOption(infosButId_)->setWidgetEnabled(false);
    }

    // Initialize the enhancements label with current cost
    if (enh_lvl < p_briefing_->nb_enhts()) {
        getStatic(txtEnhId_)->setTextFormated("%d",
            p_briefing_->enhanceCost(enh_lvl));
        getOption(enhButId_)->setWidgetEnabled(true);
    } else {
        getStatic(txtEnhId_)->setText("");
        getOption(enhButId_)->setWidgetEnabled(false);
    }

    g_System.showCursor();
}
	void CSObject::frame(const float &elapsedtime)
	{
		m_AbsolutePosition = m_RelativePosition;
		m_AbsoluteRotation = m_RelativeRotation;

		if (getParent())
		{
			m_AbsolutePosition = getParent()->getAbsolutePosition() + m_RelativePosition;
			m_AbsoluteRotation = getParent()->getAbsoluteRotation() + m_RelativeRotation;
			if (getPhysXObject())
			{
				if ( (m_AbsolutePosition != getPhysXObject()->getPosition()) ||
					(m_AbsoluteRotation != getPhysXObject()->getRotation()) )
				{
					if (getStatic()) createPhysXObject();
					else
					{
						getPhysXObject()->setPosition(m_AbsolutePosition);
						getPhysXObject()->setRotation(m_AbsoluteRotation);
					}
				}
			}
		}
		else
		if (getPhysXObject())
		{
			m_RelativePosition = m_AbsolutePosition = getPhysXObject()->getPosition();
			m_RelativeRotation = m_AbsoluteRotation = getPhysXObject()->getRotation();
		}

		setPrimarySceneNodePosition(m_AbsolutePosition);
		setPrimarySceneNodeRotation(m_AbsoluteRotation);

		if (m_Children) m_Children->frame(elapsedtime);
	}
Beispiel #6
0
/**
 * Handles when the player clicks on a agent selector.
 */
void SelectMenu::handleClickOnAgentSelector(const int agent_no, int button) {
    if (button == 3) {
        toggleAgent(agent_no);
    } else if (cur_agent_ != agent_no) {
        if (selectedWInstId_ != 0)
            updateSelectedWeapon();
        cur_agent_ = agent_no;
        if (g_Session.agents().squadMember(agent_no)) {
            getStatic(txtAgentId_)->setTextFormated("#SELECT_SUBTITLE",
                g_Session.agents().squadMember(agent_no)->getName());
        } else {
            getStatic(txtAgentId_)->setText("");
        }
        needRendering();
    }
}
Beispiel #7
0
void BriefMenu::handleShow() {

    menu_manager_->saveBackground();

    // grab mission info
    int cur_miss = g_Session.getSelectedBlock().mis_id;
    Mission *pMission = g_App.missions().loadMission(cur_miss);
    assert(pMission != NULL);
    g_Session.setMission(pMission);
    // NOTE: map is required to be loaded here, because minimap is z=0
    pMission->loadMap();

    pMission->createMinimap();
    
    bool found = false;
    int maxx = pMission->mmax_x_;
    int maxy = pMission->mmax_y_;

    for (int x = 0; x < maxx && (!found); x++) {
        for (int y = 0; y < maxy && (!found); y++) {
            if (pMission->getMinimapOverlay(x, y) == 1) {
                minimap_scroll_x_ = x;
                minimap_scroll_y_ = y;
                found = true;
            }
        }
    }

    minimap_blink_ticks_ = 0;
    minimap_blink_ = 0;
    start_line_ = 0;

    updateClock();

    if (g_Session.getSelectedBlock().infoLevel < pMission->getMaxInfoLvl()) {
        getStatic(txtInfoId_)->setTextFormated("%d",
            pMission->infoCost(g_Session.getSelectedBlock().infoLevel));
    } else
        getStatic(txtInfoId_)->setText("");
    if (g_Session.getSelectedBlock().enhanceLevel < pMission->getMaxEnhanceLvl()) {
        getStatic(txtEnhId_)->setTextFormated("%d",
            pMission->enhanceCost(g_Session.getSelectedBlock().enhanceLevel));
    } else
        getStatic(txtEnhId_)->setText("");

    g_System.showCursor();
}
Beispiel #8
0
	Variant< Event, Core::Point > PollResult::operator[](unsigned int index) const noexcept
	{
		size();
		if (index < class_1_size_) return Variant< Event, Core::Point >(getClassEvent(EventClass::class_1__, index));
		else if (index < (class_1_size_ + class_2_size_)) return Variant< Event, Core::Point >(getClassEvent(EventClass::class_2__, index - class_1_size_));
		else if (index < (class_1_size_ + class_2_size_ + class_3_size_)) return Variant< Event, Core::Point >(getClassEvent(EventClass::class_3__, index - (class_1_size_ + class_2_size_)));
		else return Variant< Event, Core::Point >(getStatic(index - (class_1_size_ + class_2_size_ + class_2_size_)));
	}
Beispiel #9
0
void DebriefMenu::checkNewWeaponFound() {

    for (int i=0; i<4; i++) {
        if (g_Session.agents().squadMember(i)) {
            Agent *pAgent = g_Session.agents().squadMember(i);
            for (int wi=0; wi < pAgent->numWeapons(); wi++) {
                Weapon *pWeapon = pAgent->weapon(wi)->getWeaponClass();

                if (!g_App.weapons().isAvailable(pWeapon)) {
                    if (g_Session.researchManager().handleWeaponDiscovered(pWeapon)) {
                        getStatic(txtNewWeap1Id_)->setText("#DEBRIEF_WEAP_FOUND1");
                        getStatic(txtNewWeap2Id_)->setText("#DEBRIEF_WEAP_FOUND2");
                    }
                }
            }
        }
    }
}
Beispiel #10
0
void DebriefMenu::handleGameEvent(GameEvent evt) {
    if (evt.type_ == GameEvent::GE_SEARCH) {
        // A research has ended
        Research *pRes = static_cast<Research *> (evt.pCtxt_);
        Weapon *pWeap = g_App.weapons().getWeapon(pRes->getSearchWeapon());

        getStatic(txtSearchId_)->setTextFormated("#DEBRIEF_SEARCH", pWeap->getName());
    }
}
	void CSObject::setRotation(vector3df rot)
	{ 
		m_RelativeRotation = rot;
		m_AbsoluteRotation = rot;

		if (getParent()) m_AbsoluteRotation = getParent()->getAbsoluteRotation() + m_RelativeRotation;
		if (getPhysXObject())
		{
			if (getStatic()) createPhysXObject();
			else getPhysXObject()->setRotation(m_AbsoluteRotation);
		}
	}
	void CSObject::setPosition(vector3df pos)
	{ 
		m_RelativePosition = pos;
		m_AbsolutePosition = pos;

		if (getParent()) m_AbsolutePosition = getParent()->getAbsolutePosition() + m_RelativePosition;
		if (getPhysXObject())
		{
			if (getStatic()) createPhysXObject();
			else getPhysXObject()->setPosition(m_AbsolutePosition);
		}
	}
Beispiel #13
0
void SelectMenu::handleShow() {

    menu_manager_->saveBackground();

    // Show the mouse
    g_System.showCursor();

    // Update the time
    updateClock();

    if (g_Session.teamMember(cur_agent_)) {
        getStatic(txtAgentId_)->setTextFormated("#SELECT_SUBTITLE", g_Session.teamMember(cur_agent_)->getName());
    } else {
        getStatic(txtAgentId_)->setText("");
    }

    for (int iAgnt=0; iAgnt<AgentManager::MAX_AGENT; iAgnt++) {
        Agent *pAgentFromCryo = g_App.agents().agent(iAgnt);
        pTeamLBox_->setSquadLine(g_Session.getTeamSlot(pAgentFromCryo), iAgnt);
    }
}
Beispiel #14
0
void DebriefMenu::handleGameEvent(GameEvent evt) {
    if (evt.type_ == GameEvent::GE_SEARCH) {
        // A research has ended, so check which type
        Research *pRes = static_cast<Research *> (evt.pCtxt_);
         // Is it equipment or mods research?
         if (pRes->getType() == Research::EQUIPS) {
             // Get researched weapon type
             Weapon::WeaponType wt= pRes->getSearchWeapon();
             assert(wt);

             // Get weapon
             Weapon *pWeap = g_App.weapons().getWeapon(wt);
             assert(pWeap);

             // Draw name of it
             getStatic(txtSearchId_)->setTextFormated("#DEBRIEF_SEARCH", pWeap->getName());
         } else {
             // Must be mods research so draw it
             getStatic(txtSearchId_)->setTextFormated("#DEBRIEF_SEARCH", pRes->getName().c_str());
         }
    }
}
Beispiel #15
0
void BriefMenu::handleAction(const int actionId, void *ctx, const int modKeys) {
    if (actionId == infosButId_) {
        // Buy some informations
        if (g_Session.getSelectedBlock().infoLevel < p_briefing_->nb_infos()) {
            g_Session.setMoney(g_Session.getMoney() - p_briefing_->infoCost(g_Session.getSelectedBlock().infoLevel));
            g_Session.getSelectedBlock().infoLevel += 1;
            
            getStatic(txtMoneyId_)->setTextFormated("%d", g_Session.getMoney());
            if (g_Session.getSelectedBlock().infoLevel < p_briefing_->nb_infos()) {
                getStatic(txtInfoId_)->setTextFormated("%d",
                    p_briefing_->infoCost(g_Session.getSelectedBlock().infoLevel));
            } else {
                getOption(infosButId_)->setWidgetEnabled(false);
                getStatic(txtInfoId_)->setText("");
            }
            update_briefing_text();
        }
    }

    if (actionId == enhButId_) {
        // Buy some map enhancement
        if (g_Session.getSelectedBlock().enhanceLevel < p_briefing_->nb_enhts()) {
            g_Session.setMoney(g_Session.getMoney() - 
                p_briefing_->enhanceCost(g_Session.getSelectedBlock().enhanceLevel));
            g_Session.getSelectedBlock().enhanceLevel += 1;
            // zoom in the minimap
            mm_renderer_.zoomOut();
            if (g_Session.getSelectedBlock().enhanceLevel == p_briefing_->nb_enhts()) {
                mm_renderer_.setDrawEnemies(true);
                getOption(enhButId_)->setWidgetEnabled(false);
            }
            redrawMiniMap();
            
            getStatic(txtMoneyId_)->setTextFormated("%d", g_Session.getMoney());
            if (g_Session.getSelectedBlock().enhanceLevel < p_briefing_->nb_enhts()) {
                getStatic(txtEnhId_)->setTextFormated("%d",
                    p_briefing_->enhanceCost(g_Session.getSelectedBlock().enhanceLevel));
            } else
                getStatic(txtEnhId_)->setText("");
        }
    }

    if (actionId == nextButId_) {
        // Next page
        start_line_ += kMaxLinePerPage;
        update_briefing_text();
    }

    if (actionId == prevButId_) {
        // Previous page
        start_line_ -= kMaxLinePerPage;
        update_briefing_text();
    }
}
Beispiel #16
0
void BriefMenu::handleAction(const int actionId, void *ctx, const int modKeys) {
    Mission *pMission = g_Session.getMission();
    if (actionId == infosButId_) {
        // Buy some informations
        if (g_Session.getSelectedBlock().infoLevel < pMission->getMaxInfoLvl()) {
            g_Session.setMoney(g_Session.getMoney() - pMission->infoCost(g_Session.getSelectedBlock().infoLevel));
            g_Session.getSelectedBlock().infoLevel += 1;
            
            getStatic(txtMoneyId_)->setTextFormated("%d", g_Session.getMoney());
            if (g_Session.getSelectedBlock().infoLevel < pMission->getMaxInfoLvl()) {
                getStatic(txtInfoId_)->setTextFormated("%d",
                    pMission->infoCost(g_Session.getSelectedBlock().infoLevel));
            } else
                getStatic(txtInfoId_)->setText("");
        }

        getOption(nextButId_)->setVisible(true);
    }

    if (actionId == enhButId_) {
        // Buy some map enhancement
        if (g_Session.getSelectedBlock().enhanceLevel < pMission->getMaxEnhanceLvl()) {
            g_Session.setMoney(g_Session.getMoney() - 
                pMission->enhanceCost(g_Session.getSelectedBlock().enhanceLevel));
            g_Session.getSelectedBlock().enhanceLevel += 1;
            
            getStatic(txtMoneyId_)->setTextFormated("%d", g_Session.getMoney());
            if (g_Session.getSelectedBlock().enhanceLevel < pMission->getMaxEnhanceLvl()) {
                getStatic(txtEnhId_)->setTextFormated("%d",
                    pMission->enhanceCost(g_Session.getSelectedBlock().enhanceLevel));
            } else
                getStatic(txtEnhId_)->setText("");
        }
    }

    if (actionId == nextButId_) {
        // Next page
        start_line_ += 14;
        getOption(prevButId_)->setVisible(true);
        needRendering();
    }

    if (actionId == prevButId_) {
        // Previous page
        start_line_ -= 14;

        if (start_line_ <= 0) {
            start_line_ = 0;
            getOption(prevButId_)->setVisible(false);
        }
        getOption(nextButId_)->setVisible(true);
        needRendering();
    }
}
Beispiel #17
0
void SelectMenu::handleAction(const int actionId, void *ctx, const int modKeys)
{
    if (actionId == teamButId_) {
        tab_ = TAB_TEAM;
        showItemList();
    } else if (actionId == modsButId_) {
        tab_ = TAB_MODS;
        showItemList();
    } else if (actionId == equipButId_) {
        tab_ = TAB_EQUIPS;
        showItemList();
    } else if (actionId == pTeamLBox_->getId()) {
        // get the selected agent from the team listbox
        std::pair<int, void *> * pPair = static_cast<std::pair<int, void *> *> (ctx);
        Agent *pNewAgent = static_cast<Agent *> (pPair->second);
        
        bool found = false;
        // check if selected agent is already part of the mission squad
        for (size_t j = 0; j < AgentManager::kMaxSlot; j++) {
            if (g_Session.agents().squadMember(j) == pNewAgent) {
                found = true;
                break;
            }
        }

        // Agent was not part of the squad
        if (!found) {
            // adds him to the squad
            g_Session.agents().setSquadMember(cur_agent_, pNewAgent);
            // Update current agent name
            getStatic(txtAgentId_)->setTextFormated("#SELECT_SUBTITLE", pNewAgent->getName());
            pTeamLBox_->setSquadLine(cur_agent_, pPair->first);
            updateAcceptEnabled();

            // redraw agent display
            addDirtyRect(158, 110, 340, 260);
            // redraw agent buttons
            dirtyAgentSelector();
        }
        
    } else if (actionId == pModsLBox_->getId()) {
        std::pair<int, void *> * pPair = static_cast<std::pair<int, void *> *> (ctx);
        pSelectedMod_ = static_cast<Mod *> (pPair->second);
        showModWeaponPanel();
    } else if (actionId == pWeaponsLBox_->getId()) {
        std::pair<int, void *> * pPair = static_cast<std::pair<int, void *> *> (ctx);
        pSelectedWeap_ = static_cast<Weapon *> (pPair->second);
        showModWeaponPanel();
    } else if (actionId == cancelButId_) {
        showItemList();
    } else if (actionId == reloadButId_) {
        Agent *selected = g_Session.agents().squadMember(cur_agent_);
        WeaponInstance *wi = selected->weapon(selectedWInstId_ - 1);
        int rldCost = (pSelectedWeap_->ammo()
                        - wi->ammoRemaining()) * pSelectedWeap_->ammoCost();

        if (g_Session.getMoney() >= rldCost) {
            g_Session.setMoney(g_Session.getMoney() - rldCost);
            wi->setAmmoRemaining(pSelectedWeap_->ammo());
            getOption(reloadButId_)->setVisible(false);
            getStatic(moneyTxtId_)->setTextFormated("%d", g_Session.getMoney());
        }
    } else if (actionId == purchaseButId_) {
        // Buying weapon
        if (pSelectedWeap_) {
            if (sel_all_) {
                for (int n = 0; n < 4; n++) {
                    Agent *selected = g_Session.agents().squadMember(n);
                    if (selected && selected->numWeapons() < 8
                        && g_Session.getMoney() >= pSelectedWeap_->cost()) {
                        g_Session.setMoney(g_Session.getMoney() - pSelectedWeap_->cost());
                        selected->addWeapon(pSelectedWeap_->createInstance());
                        getStatic(moneyTxtId_)->setTextFormated("%d", g_Session.getMoney());
                    }
                }
            } else {
                Agent *selected = g_Session.agents().squadMember(cur_agent_);
                if (selected && selected->numWeapons() < 8
                    && g_Session.getMoney() >= pSelectedWeap_->cost()) {
                    g_Session.setMoney(g_Session.getMoney() - pSelectedWeap_->cost());
                    selected->addWeapon(pSelectedWeap_->createInstance());
                    getStatic(moneyTxtId_)->setTextFormated("%d", g_Session.getMoney());
                }
            }
            needRendering();
        } else if (pSelectedMod_) {
            if (sel_all_) {
                for (int n = 0; n < 4; n++) {
                    Agent *selected = g_Session.agents().squadMember(n);
                    if (selected && selected->canHaveMod(pSelectedMod_)
                        && g_Session.getMoney() >= pSelectedMod_->cost()) {
                        selected->addMod(pSelectedMod_);
                        g_Session.setMoney(g_Session.getMoney() - pSelectedMod_->cost());
                        getStatic(moneyTxtId_)->setTextFormated("%d", g_Session.getMoney());
                    }
                }
            } else {
                Agent *selected = g_Session.agents().squadMember(cur_agent_);
                if (selected && selected->canHaveMod(pSelectedMod_)
                    && g_Session.getMoney() >= pSelectedMod_->cost()) {
                    selected->addMod(pSelectedMod_);
                    g_Session.setMoney(g_Session.getMoney() - pSelectedMod_->cost());
                    getStatic(moneyTxtId_)->setTextFormated("%d", g_Session.getMoney());
                }
            }
            showItemList();
        }
    
    } else if (actionId == sellButId_ && selectedWInstId_) {
        addDirtyRect(360, 305, 135, 70);
        Agent *selected = g_Session.agents().squadMember(cur_agent_);
        WeaponInstance *pWi = selected->removeWeapon(selectedWInstId_ - 1);
        g_Session.setMoney(g_Session.getMoney() + pWi->getWeaponClass()->cost());
        getStatic(moneyTxtId_)->setTextFormated("%d", g_Session.getMoney());
        delete pWi;
        showItemList();
    }
}
Beispiel #18
0
void DebriefMenu::updateStatsFields(Mission *pMission) {
    MissionStats *pStats = pMission->getStatistics();

    if (pMission->getStatus() == Mission::FAILED) {
        getStatic(txtStatusId_)->setText("#DEBRIEF_MIS_FAILED");
    } else if (pMission->getStatus() == Mission::COMPLETED) {
        getStatic(txtStatusId_)->setText("#DEBRIEF_MIS_COMP");
    } else if (pMission->getStatus() == Mission::ABORTED) {
        getStatic(txtStatusId_)->setText("#DEBRIEF_MIS_ABORT");
    }

    getStatic(txtUsedId_)->setTextFormated("%i", pStats->agents);
    getStatic(txtAgentCapturedId_)->setTextFormated("%i", pStats->agentCaptured);

    int days = 0;
    int hours = 0;
    g_Session.getDayHourFromPeriod(pStats->mission_duration, days, hours);
    getStatic(txtTimeId_)->setTextFormated("#DEBRIEF_TIME_FORMAT", hours, days);
    getStatic(txtAgentKilledId_)->setTextFormated("%i", pStats->enemyKilled);
    getStatic(txtCrimKilledId_)->setTextFormated("%i", pStats->criminalKilled);
    getStatic(txtCivilKilledId_)->setTextFormated("%i", pStats->civilKilled);
    getStatic(txtPoliceKilledId_)->setTextFormated("%i", pStats->policeKilled);
    getStatic(txtGardKilledId_)->setTextFormated("%i", pStats->guardKilled);
    getStatic(txtConvincedId_)->setTextFormated("%i", pStats->convinced);

    if (pStats->nbOfShots == 0) {
        getStatic(txtPrecisionId_)->setText("#DEBRIEF_NO_BULLET");
    } else {
        // NOTE: we count persudatron direct uses too, although don't count
        // hits for objects other then original target
        int precision = (pStats->nbOfHits * 100) / pStats->nbOfShots ;
        getStatic(txtPrecisionId_)->setTextFormated("%i%%", precision);
    }
}
Beispiel #19
0
bool SelectMenu::handleMouseDown(int x, int y, int button, const int modKeys)
{
    if (x >= 20 && x <= 140) {
        if (y >= 84 && y <= 150) {
            if (x >= 82) {
                if (button == 3)
                    toggleAgent(1);
                else {
                    cur_agent_ = 1;
                    if (g_Session.teamMember(1)) {
                        getStatic(txtAgentId_)->setTextFormated("#SELECT_SUBTITLE", g_Session.teamMember(1)->getName());
                    } else {
                        getStatic(txtAgentId_)->setText("");
                    }
                }
            } else {
                if (button == 3)
                    toggleAgent(0);
                else {
                    cur_agent_ = 0;
                    if (g_Session.teamMember(0)) {
                        getStatic(txtAgentId_)->setTextFormated("#SELECT_SUBTITLE", g_Session.teamMember(0)->getName());
                    } else {
                        getStatic(txtAgentId_)->setText("");
                    }
                }
            }
            needRendering();
        }
        if (y > 150 && y < 162) {
            sel_all_ = !sel_all_;
            needRendering();
        }
        if (y >= 162 && y <= 228) {
            if (x >= 82) {
                if (button == 3)
                    toggleAgent(3);
                else {
                    cur_agent_ = 3;
                    if (g_Session.teamMember(3)) {
                        getStatic(txtAgentId_)->setTextFormated("#SELECT_SUBTITLE", g_Session.teamMember(3)->getName());
                    } else {
                        getStatic(txtAgentId_)->setText("");
                    }
                }
            } else {
                if (button == 3)
                    toggleAgent(2);
                else {
                    cur_agent_ = 2;
                    if (g_Session.teamMember(2)) {
                        getStatic(txtAgentId_)->setTextFormated("#SELECT_SUBTITLE", g_Session.teamMember(2)->getName());
                    } else {
                        getStatic(txtAgentId_)->setText("");
                    }
                }
            }
            needRendering();
        }
    }

	// Checks if the user clicked on item in the current agent inventory
    Agent *selected = g_Session.teamMember(cur_agent_);
    if (selected) {
        for (int j = 0; j < 2; j++)
            for (int i = 0; i < 4; i++)
                if (j * 4 + i < selected->numWeapons() &&
                    x >= 366 + i * 32 && x < 366 + i * 32 + 32 &&
                    y >= 308 + j * 32 && y < 308 + j * 32 + 32)
                {
					// The user has actually selected a weapon from the inventory :
					// 1/ selects the EQUIPS toggle button
                    tab_ = TAB_EQUIPS;
                    pSelectedMod_ = NULL;
                    selectToggleAction(equipButId_);
					// 2/ computes the id of the selected weapon and selects it
					int newId = i + j * 4 + 1;

					if (newId != selectedWInstId_) { // Do something only if a different weapon is selected
						selectedWInstId_ = newId;
						WeaponInstance *wi = selected->weapon(selectedWInstId_ -1);
						pSelectedWeap_ = wi->getWeaponClass();
						addDirtyRect(500, 105,  125, 235);
						// 3/ see if reload button should be displayed
						bool displayReload = pSelectedWeap_->ammo() > wi->ammoRemaining();
						getOption(reloadButId_)->setVisible(displayReload);

						// 4/ hides the purchase button for the sell button
						getOption(purchaseButId_)->setVisible(false);
						getOption(cancelButId_)->setVisible(true);
						getOption(sellButId_)->setVisible(true);
						pTeamLBox_->setVisible(false);
						pModsLBox_->setVisible(false);
						pWeaponsLBox_->setVisible(false);
					}
                }
    }

	return false;
}