Ejemplo n.º 1
0
void SkillEditor::_ReloadTab()
{

    if(_GetCurrentSkillList().empty()) {
        return;
    }

    GlobalSkill *skill = _GetCurrentSkillList()[_current_skill_index[_current_tab]];

    string text = MakeStandardString(skill->GetName());
    _le_skill_names[_current_tab]->setText(QString(text.c_str()));

    text = MakeStandardString(skill->GetDescription());
    _le_description[_current_tab]->setText(QString(text.c_str()));

    text = NumberToString<uint32>(skill->GetSPRequired());
    _le_sp_required[_current_tab]->setText(QString(text.c_str()));

    text = NumberToString<uint32>(skill->GetWarmupTime());
    _le_warmup_time[_current_tab]->setText(QString(text.c_str()));

    text = NumberToString<uint32>(skill->GetCooldownTime());
    _le_cooldown_time[_current_tab]->setText(QString(text.c_str()));

    _cb_target_type[_current_tab]->setCurrentIndex(static_cast<int32>(skill->GetTargetType()));

    // TODO: as more controls are added to the tab, reload them here.
}
Ejemplo n.º 2
0
bool GlobalEnemy::AddSkill(uint32_t skill_id)
{
    if(skill_id == 0) {
        IF_PRINT_WARNING(GLOBAL_DEBUG) << "function received an invalid skill_id argument: " << skill_id << std::endl;
        return false;
    }

    if(HasSkill(skill_id)) {
        IF_PRINT_WARNING(GLOBAL_DEBUG) << "failed to add skill because the enemy already knew this skill: " << skill_id << std::endl;
        return false;
    }

    GlobalSkill *skill = new GlobalSkill(skill_id);
    if(skill->IsValid() == false) {
        IF_PRINT_WARNING(GLOBAL_DEBUG) << "the skill to add failed to load: " << skill_id << std::endl;
        delete skill;
        return false;
    }

    // Insert the pointer to the new skill inside of the global skills vectors
    _skills.push_back(skill);
    _skills_id.push_back(skill_id);
    return true;
}
Ejemplo n.º 3
0
void MenuMode::UpdateEquipmentInfo(GlobalCharacter *character, GlobalObject *object, EQUIP_VIEW view_type)
{
    // Only update when necessary
    if ((_object == object) && (_character == character) && (_equip_view_type == view_type))
        return;
    if (view_type == EQUIP_VIEW_NONE)
        return;

    _object = object;
    _character = character;
    _equip_view_type = view_type;

    // Clear the corresponding texts when there is no corresponding data
    if (!_object) {
        _object_name.Clear();
        _elemental_icons.clear();
        _status_icons.clear();
        _spirit_number = 0;
        _equip_skills.clear();
        _equip_skill_icons.clear();

        _phys_header.Clear();
        _mag_header.Clear();
        _phys_stat.Clear();
        _mag_stat.Clear();
    }

    // Don't show any diff when there no slected character,
    // or not showing equip/unequip diffs.
    if (!_character || view_type == EQUIP_VIEW_CHAR) {
        _phys_stat_diff.Clear();
        _mag_stat_diff.Clear();
    }

    // If there is no object, we can return here.
    if (!_object)
        return;

    _object_name.SetText(_object->GetName());

    // Loads elemental icons
    const std::vector<std::pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY> >& elemental_effects = _object->GetElementalEffects();
    _elemental_icons.clear();
    for(std::vector<std::pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY> >::const_iterator it = elemental_effects.begin();
            it != elemental_effects.end(); ++it) {
        if(it->second != GLOBAL_INTENSITY_NEUTRAL)
            _elemental_icons.push_back(GlobalManager->Media().GetElementalIcon(it->first, it->second));
    }

    // Loads status effects.
    const std::vector<std::pair<GLOBAL_STATUS, GLOBAL_INTENSITY> >& status_effects = _object->GetStatusEffects();
    _status_icons.clear();
    for(std::vector<std::pair<GLOBAL_STATUS, GLOBAL_INTENSITY> >::const_iterator it = status_effects.begin();
            it != status_effects.end(); ++it) {
        if(it->second != GLOBAL_INTENSITY_NEUTRAL)
            _status_icons.push_back(GlobalManager->Media().GetStatusIcon(it->first, it->second));
    }

    uint32 equip_phys_stat = 0;
    uint32 equip_mag_stat = 0;

    switch (_object->GetObjectType()) {
        default: // Should never happen
            return;
        case GLOBAL_OBJECT_WEAPON: {
            _is_weapon = true;
            GlobalWeapon* wpn = NULL;
            // If character view or unequipping, we take the character current weapon as a base
            if (view_type == EQUIP_VIEW_CHAR || view_type == EQUIP_VIEW_UNEQUIPPING)
                wpn = _character ? _character->GetWeaponEquipped() : NULL;
            else // We can take the given object as a base
                wpn = dynamic_cast<GlobalWeapon *>(_object);

            _spirit_number = wpn ? wpn->GetSpiritSlots().size() : 0;
            equip_phys_stat = wpn ? wpn->GetPhysicalAttack() : 0;
            equip_mag_stat = wpn ? wpn->GetMagicalAttack() : 0;

            const std::vector<uint32>& equip_skills = wpn->GetEquipmentSkills();
            _equip_skills.clear();
            _equip_skill_icons.clear();
            // Display a max of 5 skills
            for (uint32 i = 0; i < equip_skills.size() && i < 5; ++i) {
                GlobalSkill *skill = new GlobalSkill(equip_skills[i]);
                if (skill && skill->IsValid()) {
                    _equip_skills.push_back(vt_video::TextImage(skill->GetName(), TextStyle("text20")));
                    _equip_skill_icons.push_back(vt_video::StillImage());
                    vt_video::StillImage& img = _equip_skill_icons.back();
                    img.Load(skill->GetIconFilename());
                    img.SetWidthKeepRatio(15.0f);
                }
                delete skill;
            }
            break;
        }

        case GLOBAL_OBJECT_HEAD_ARMOR:
        case GLOBAL_OBJECT_TORSO_ARMOR:
        case GLOBAL_OBJECT_ARM_ARMOR:
        case GLOBAL_OBJECT_LEG_ARMOR:
        {
            _is_weapon = false;
            GlobalArmor* armor = NULL;

            // If character view or unequipping, we take the character current armor as a base
            if (view_type == EQUIP_VIEW_CHAR || view_type == EQUIP_VIEW_UNEQUIPPING) {
                uint32 equip_index = GetEquipmentPositionFromObjectType(_object->GetObjectType());
                armor = _character ? _character->GetArmorEquipped(equip_index) : NULL;
            }
            else { // We can take the given object as a base
                armor = dynamic_cast<GlobalArmor *>(_object);
            }

            _spirit_number = armor ? armor->GetSpiritSlots().size() : 0;
            equip_phys_stat = armor ? armor->GetPhysicalDefense() : 0;
            equip_mag_stat = armor ? armor->GetMagicalDefense() : 0;

            const std::vector<uint32>& equip_skills = armor->GetEquipmentSkills();
            _equip_skills.clear();
            _equip_skill_icons.clear();
            // Display a max of 5 skills
            for (uint32 i = 0; i < equip_skills.size() && i < 5; ++i) {
                GlobalSkill *skill = new GlobalSkill(equip_skills[i]);
                if (skill && skill->IsValid()) {
                    _equip_skills.push_back(vt_video::TextImage(skill->GetName(), TextStyle("text20")));
                    _equip_skill_icons.push_back(vt_video::StillImage());
                    vt_video::StillImage& img = _equip_skill_icons.back();
                    img.Load(skill->GetIconFilename());
                    img.SetWidthKeepRatio(15.0f);
                }
                delete skill;
            }
            break;
        }
    }

    if (_is_weapon) {
        _phys_header.SetText(UTranslate("ATK:"));
        _mag_header.SetText(UTranslate("M.ATK:"));
    }
    else {
        _phys_header.SetText(UTranslate("DEF:"));
        _mag_header.SetText(UTranslate("M.DEF:"));
    }

    _phys_stat.SetText(NumberToString(equip_phys_stat));
    _mag_stat.SetText(NumberToString(equip_mag_stat));

    // We can stop here if there is no valid character, or simply showing
    // the object stats
    if (!_character || view_type == EQUIP_VIEW_CHAR)
        return;

    int32 phys_stat_diff = 0;
    int32 mag_stat_diff = 0;

    if (_is_weapon) {
        // Get the character's current attack
        GlobalWeapon* wpn = _character->GetWeaponEquipped();
        uint32 char_phys_stat = 0;
        uint32 char_mag_stat = 0;
        if (_equip_view_type == EQUIP_VIEW_EQUIPPING) {
            char_phys_stat = (wpn ? wpn->GetPhysicalAttack() : 0);
            char_mag_stat = (wpn ? wpn->GetMagicalAttack() : 0);

            phys_stat_diff = equip_phys_stat - char_phys_stat;
            mag_stat_diff = equip_mag_stat - char_mag_stat;
        }
        else { // unequipping
            phys_stat_diff = char_phys_stat - equip_phys_stat;
            mag_stat_diff = char_mag_stat - equip_mag_stat;
        }
    }
    else { // armors
        uint32 equip_index = GetEquipmentPositionFromObjectType(_object->GetObjectType());
        GlobalArmor* armor = _character->GetArmorEquipped(equip_index);
        uint32 char_phys_stat = 0;
        uint32 char_mag_stat = 0;
        if (_equip_view_type == EQUIP_VIEW_EQUIPPING) {
            char_phys_stat = (armor ? armor->GetPhysicalDefense() : 0);
            char_mag_stat = (armor ? armor->GetMagicalDefense() : 0);

            phys_stat_diff = equip_phys_stat - char_phys_stat;
            mag_stat_diff = equip_mag_stat - char_mag_stat;
        }
        else { // unequiping
            phys_stat_diff = char_phys_stat - equip_phys_stat;
            mag_stat_diff = char_mag_stat - equip_mag_stat;
        }
    }

    // Compute the overall stats diff with selected equipment
    if (phys_stat_diff > 0) {
        _phys_stat_diff.SetText("+" + NumberToString(phys_stat_diff));
        _phys_diff_color.SetColor(Color::green);
    }
    else if (phys_stat_diff < 0) {
        _phys_stat_diff.SetText(NumberToString(phys_stat_diff));
        _phys_diff_color.SetColor(Color::red);
    }
    else {
        _phys_stat_diff.Clear();
    }

    if (mag_stat_diff > 0) {
        _mag_stat_diff.SetText("+" + NumberToString(mag_stat_diff));
        _mag_diff_color.SetColor(Color::green);
    }
    else if (mag_stat_diff < 0) {
        _mag_stat_diff.SetText(NumberToString(mag_stat_diff));
        _mag_diff_color.SetColor(Color::red);
    }
    else {
        _mag_stat_diff.Clear();
    }
}
Ejemplo n.º 4
0
void SkillEditor::_CreateTab(GLOBAL_SKILL type, vector<GlobalSkill *>skills, QString tab_name)
{
    _gl_layouts[type] = new QGridLayout();
    // add the labels for the different parts of the skill
    _lbl_skill_names[type] = new QLabel();
    _lbl_skill_names[type]->setText("Skill Name:");
    _gl_layouts[type]->addWidget(_lbl_skill_names[type], 0, 0);

    _lbl_description[type] = new QLabel();
    _lbl_description[type]->setText("Description:");
    _gl_layouts[type]->addWidget(_lbl_description[type], 1, 0);

    _lbl_sp_required[type] = new QLabel();
    _lbl_sp_required[type]->setText("SP Required:");
    _gl_layouts[type]->addWidget(_lbl_sp_required[type], 2, 0);

    _lbl_warmup_time[type] = new QLabel();
    _lbl_warmup_time[type]->setText("Warmup Time:");
    _gl_layouts[type]->addWidget(_lbl_warmup_time[type], 2, 2);

    _lbl_cooldown_time[type] = new QLabel();
    _lbl_cooldown_time[type]->setText("Cooldown Time:");
    _gl_layouts[type]->addWidget(_lbl_cooldown_time[type], 3, 0);

    _lbl_target_type[type] = new QLabel();
    _lbl_target_type[type]->setText("Target Type:");
    _gl_layouts[type]->addWidget(_lbl_target_type[type], 4, 0);

    // add the line edits for the skill
    _le_skill_names[type] = new QLineEdit();
    _le_description[type] = new QLineEdit();
    _le_sp_required[type] = new QLineEdit();
    _le_warmup_time[type] = new QLineEdit();
    _le_cooldown_time[type] = new QLineEdit();
    _cb_target_type[type] = new QComboBox();

    if(_current_skill_index[type] != -1) {
        GlobalSkill *skill = skills[_current_skill_index[type]];
        // this skill is enabled so set the text
        string text = MakeStandardString(skill->GetName());
        // get the char array from the standard string, because otherwise the QString ends up with
        // some gibberish text at the beginning of it
        _le_skill_names[type]->setText(QString(text.c_str()));

        text = MakeStandardString(skill->GetDescription());
        _le_description[type]->setText(QString(text.c_str()));

        text = NumberToString<uint32>(skill->GetSPRequired());
        _le_sp_required[type]->setText(QString(text.c_str()));

        text = NumberToString<uint32>(skill->GetWarmupTime());
        _le_warmup_time[type]->setText(QString(text.c_str()));

        text = NumberToString<uint32>(skill->GetCooldownTime());
        _le_cooldown_time[type]->setText(QString(text.c_str()));

        _cb_target_type[type]->insertItem("Attack Point");
        _cb_target_type[type]->insertItem("Actor");
        _cb_target_type[type]->insertItem("Party");
        _cb_target_type[type]->setCurrentIndex(static_cast<int32>(skill->GetTargetType()));
    } else {
        // disable the line edits (no skills for this group)
        _le_skill_names[type]->setDisabled(true);
        _le_description[type]->setDisabled(true);
        _le_sp_required[type]->setDisabled(true);
        _le_warmup_time[type]->setDisabled(true);
        _le_cooldown_time[type]->setDisabled(true);
        _cb_target_type[type]->setDisabled(true);
        _rb_target_ally_false[type]->setDisabled(true);
        _rb_target_ally_true[type]->setDisabled(true);
    }

    // add above widgets to grid layout
    _gl_layouts[type]->addWidget(_le_skill_names[type], 0, 1, 1, 3);
    _gl_layouts[type]->addWidget(_le_description[type], 1, 1, 1, 3);
    _gl_layouts[type]->addWidget(_le_sp_required[type], 2, 1);
    _gl_layouts[type]->addWidget(_le_warmup_time[type], 2, 3);
    _gl_layouts[type]->addWidget(_le_cooldown_time[type], 3, 1);
    _gl_layouts[type]->addWidget(_cb_target_type[type], 4, 1);
    _hbox_target_ally[type] = new QHBoxLayout();
    _hbox_target_ally[type]->addWidget(_rb_target_ally_true[type]);
    _hbox_target_ally[type]->addWidget(_rb_target_ally_false[type]);
    _target_ally_spacers[type] = new QSpacerItem(10, 5, QSizePolicy::Expanding);
    _hbox_target_ally[type]->addItem(_target_ally_spacers[type]);
    _gl_layouts[type]->addLayout(_hbox_target_ally[type], 3, 3);

    // create the vertical layout for the tab
    _tab_vboxes[type] = new QVBoxLayout();
    _tab_vboxes[type]->addLayout(_gl_layouts[type]);

    // add a spacer to the vbox to push up the grid layout
    _tab_spacers[type] = new QSpacerItem(10, 5, QSizePolicy::Minimum, QSizePolicy::Expanding);
    _tab_vboxes[type]->addItem(_tab_spacers[type]);

    // create the horizontal layout underneath the grid in the tab
    _tab_bottom_hboxes[type] = new QHBoxLayout();

    _CreateTabBottomButtons(type);

    _tab_vboxes[type]->addLayout(_tab_bottom_hboxes[type]);

    _tab_pages[type] = new QWidget();
    _tab_pages[type]->setLayout(_tab_vboxes[type]);
    _tab_skill_groups->addTab(_tab_pages[type], tab_name);
} // _CreateTab(GLOBAL_SKILL)