Exemplo n.º 1
0
void StatsWindow::setValue (const std::string& id, const MWMechanics::DynamicStat<int>& value)
{
    static const char *ids[] =
    {
        "HBar", "MBar", "FBar",
        0
    };

    for (int i=0; ids[i]; ++i)
    {
        if (ids[i]==id)
        {
            std::string id (ids[i]);
            setBar (id, id + "T", value.getCurrent(), value.getModified());

            // health, magicka, fatigue tooltip
            MyGUI::Widget* w;
            std::string valStr =  boost::lexical_cast<std::string>(value.getCurrent()) + "/" + boost::lexical_cast<std::string>(value.getModified());
            if (i==0)
            {
                getWidget(w, "Health");
                w->setUserString("Caption_HealthDescription", "#{sHealthDesc}\n" + valStr);
            }
            else if (i==1)
            {
                getWidget(w, "Magicka");
                w->setUserString("Caption_HealthDescription", "#{sIntDesc}\n" + valStr);
            }
            else if (i==2)
            {
                getWidget(w, "Fatigue");
                w->setUserString("Caption_HealthDescription", "#{sFatDesc}\n" + valStr);
            }
        }
    }
}
Exemplo n.º 2
0
void StatsWindow::updateSkillArea()
{
    mChanged = false;

    for (std::vector<MyGUI::WidgetPtr>::iterator it = skillWidgets.begin(); it != skillWidgets.end(); ++it)
    {
        MyGUI::Gui::getInstance().destroyWidget(*it);
    }
    skillWidgets.clear();

    skillScrollerWidget->setScrollPosition(0);
    onScrollChangePosition(skillScrollerWidget, 0);
    clientHeight = 0;

    const int valueSize = 40;
    MyGUI::IntCoord coord1(10, 0, skillClientWidget->getWidth() - (10 + valueSize), 18);
    MyGUI::IntCoord coord2(coord1.left + coord1.width, coord1.top, valueSize, coord1.height);

    if (!majorSkills.empty())
        addSkills(majorSkills, "sSkillClassMajor", "Major Skills", coord1, coord2);

    if (!minorSkills.empty())
        addSkills(minorSkills, "sSkillClassMinor", "Minor Skills", coord1, coord2);

    if (!miscSkills.empty())
        addSkills(miscSkills, "sSkillClassMisc", "Misc Skills", coord1, coord2);

    const ESMS::ESMStore &store = mWindowManager.getStore();

    // race tooltip
    const ESM::Race* playerRace =  store.races.find (MWBase::Environment::get().getWorld()->getPlayer().getRace());
    MyGUI::Widget* raceWidget;
    getWidget(raceWidget, "RaceText");
    ToolTips::createRaceToolTip(raceWidget, playerRace);
    getWidget(raceWidget, "Race_str");
    ToolTips::createRaceToolTip(raceWidget, playerRace);

    // class tooltip
    MyGUI::Widget* classWidget;
    const ESM::Class& playerClass = MWBase::Environment::get().getWorld()->getPlayer().getClass();
    getWidget(classWidget, "ClassText");
    ToolTips::createClassToolTip(classWidget, playerClass);
    getWidget(classWidget, "Class_str");
    ToolTips::createClassToolTip(classWidget, playerClass);

    if (!mFactions.empty())
    {
        // Add a line separator if there are items above
        if (!skillWidgets.empty())
            addSeparator(coord1, coord2);

        addGroup(mWindowManager.getGameSettingString("sFaction", "Faction"), coord1, coord2);
        FactionList::const_iterator end = mFactions.end();
        for (FactionList::const_iterator it = mFactions.begin(); it != end; ++it)
        {
            const ESM::Faction *faction = store.factions.find(it->first);
            MyGUI::Widget* w = addItem(faction->name, coord1, coord2);

            std::string text;

            text += std::string("#DDC79E") + faction->name;
            text += std::string("\n#BF9959") + faction->ranks[it->second];

            if (it->second < 9)
            {
                // player doesn't have max rank yet
                text += std::string("\n\n#DDC79E#{sNextRank} ") + faction->ranks[it->second+1];

                ESM::RankData rankData = faction->data.rankData[it->second+1];
                const ESM::Attribute* attr1 = mWindowManager.getStore().attributes.search(faction->data.attribute1);
                const ESM::Attribute* attr2 = mWindowManager.getStore().attributes.search(faction->data.attribute2);
                assert(attr1 && attr2);

                text += "\n#BF9959#{" + attr1->name + "}: " + boost::lexical_cast<std::string>(rankData.attribute1)
                        + ", #{" + attr2->name + "}: " + boost::lexical_cast<std::string>(rankData.attribute2);

                text += "\n\n#DDC79E#{sFavoriteSkills}";
                text += "\n#BF9959";
                for (int i=0; i<6; ++i)
                {
                    const ESM::Skill* skill = mWindowManager.getStore().skills.search(faction->data.skillID[i]);
                    assert(skill);
                    text += "#{"+ESM::Skill::sSkillNameIds[faction->data.skillID[i]]+"}";
                    if (i<5)
                        text += ", ";
                }

                text += "\n";

                if (rankData.skill1 > 0)
                    text += "\n#{sNeedOneSkill} " + boost::lexical_cast<std::string>(rankData.skill1);
                if (rankData.skill2 > 0)
                    text += "\n#{sNeedTwoSkills} " + boost::lexical_cast<std::string>(rankData.skill2);
            }

            w->setUserString("ToolTipType", "Layout");
            w->setUserString("ToolTipLayout", "TextToolTip");
            w->setUserString("Caption_Text", text);
        }
    }

    if (!birthSignId.empty())
    {
        // Add a line separator if there are items above
        if (!skillWidgets.empty())
            addSeparator(coord1, coord2);

        addGroup(mWindowManager.getGameSettingString("sBirthSign", "Sign"), coord1, coord2);
        const ESM::BirthSign *sign = store.birthSigns.find(birthSignId);
        MyGUI::Widget* w = addItem(sign->name, coord1, coord2);

        ToolTips::createBirthsignToolTip(w, birthSignId);
    }

    // Add a line separator if there are items above
    if (!skillWidgets.empty())
        addSeparator(coord1, coord2);

    addValueItem(mWindowManager.getGameSettingString("sReputation", "Reputation"),
                boost::lexical_cast<std::string>(static_cast<int>(reputation)), "normal", coord1, coord2);

    for (int i=0; i<2; ++i)
    {
        skillWidgets[skillWidgets.size()-1-i]->setUserString("ToolTipType", "Layout");
        skillWidgets[skillWidgets.size()-1-i]->setUserString("ToolTipLayout", "TextToolTip");
        skillWidgets[skillWidgets.size()-1-i]->setUserString("Caption_Text", "#{sSkillsMenuReputationHelp}");
    }
    
    addValueItem(mWindowManager.getGameSettingString("sBounty", "Bounty"),
                boost::lexical_cast<std::string>(static_cast<int>(bounty)), "normal", coord1, coord2);

    for (int i=0; i<2; ++i)
    {
        skillWidgets[skillWidgets.size()-1-i]->setUserString("ToolTipType", "Layout");
        skillWidgets[skillWidgets.size()-1-i]->setUserString("ToolTipLayout", "TextToolTip");
        skillWidgets[skillWidgets.size()-1-i]->setUserString("Caption_Text", "#{sCrimeHelp}");
    }

    clientHeight = coord1.top;
    updateScroller();
}