Skill::Secondary Dialog::SelectSecondarySkill(void) { Display & display = Display::Get(); Cursor & cursor = Cursor::Get(); LocalEvent & le = LocalEvent::Get(); std::vector<int> skills(MAXSECONDARYSKILL * 3, 0); cursor.Hide(); cursor.SetThemes(cursor.POINTER); for(size_t ii = 0; ii < MAXSECONDARYSKILL * 3; ++ii) skills[ii] = ii; const u16 window_w = 310; const u16 window_h = 280; Dialog::FrameBorder frameborder; frameborder.SetPosition((display.w() - window_w) / 2 - BORDERWIDTH, (display.h() - window_h) / 2 - BORDERWIDTH, window_w, window_h); frameborder.Redraw(AGG::GetICN(ICN::TEXTBAK2, 0)); const Rect & area = frameborder.GetArea(); SelectEnumSecSkill listbox(area); listbox.SetListContent(skills); listbox.Redraw(); ButtonGroups btnGroups(area, Dialog::OK|Dialog::CANCEL); btnGroups.Draw(); cursor.Show(); display.Flip(); u16 result = Dialog::ZERO; while(result == Dialog::ZERO && ! listbox.ok && le.HandleEvents()) { result = btnGroups.QueueEventProcessing(); listbox.QueueEventProcessing(); if(!cursor.isVisible()) { listbox.Redraw(); cursor.Show(); display.Flip(); } } Skill::Secondary skill; if(result == Dialog::OK || listbox.ok) { skill.SetSkill(1 + (listbox.GetCurrent() / 3)); skill.SetLevel(1 + (listbox.GetCurrent() % 3)); } return skill; }
void Battle::EagleEyeSkillAction(HeroBase & hero, const SpellStorage & spells, bool local) { if(spells.empty() || !hero.HaveSpellBook()) return; SpellStorage new_spells; new_spells.reserve(10); const Skill::Secondary eagleeye(Skill::Secondary::EAGLEEYE, hero.GetLevelSkill(Skill::Secondary::EAGLEEYE)); // filter spells for(SpellStorage::const_iterator it = spells.begin(); it != spells.end(); ++it) { const Spell & sp = *it; if(!hero.HaveSpell(sp)) { switch(eagleeye.Level()) { case Skill::Level::BASIC: // 20% if(3 > sp.Level() && eagleeye.GetValues() >= Rand::Get(1, 100)) new_spells.push_back(sp); break; case Skill::Level::ADVANCED: // 30% if(4 > sp.Level() && eagleeye.GetValues() >= Rand::Get(1, 100)) new_spells.push_back(sp); break; case Skill::Level::EXPERT: // 40% if(5 > sp.Level() && eagleeye.GetValues() >= Rand::Get(1, 100)) new_spells.push_back(sp); break; default: break; } } } // add new spell for(SpellStorage::const_iterator it = new_spells.begin(); it != new_spells.end(); ++it) { const Spell & sp = *it; if(local) { std::string msg = _("Through eagle-eyed observation, %{name} is able to learn the magic spell %{spell}."); String::Replace(msg, "%{name}", hero.GetName()); String::Replace(msg, "%{spell}", sp.GetName()); Game::PlayPickupSound(); Dialog::SpellInfo("", msg, sp); } } hero.AppendSpellsToBook(new_spells, true); }
void Skill::SecSkills::AddSkill(const Skill::Secondary & skill) { iterator it = std::find_if(begin(), end(), std::bind2nd(std::mem_fun_ref(&Secondary::isSkill), skill.Skill())); if(it != end()) (*it).SetLevel(skill.Level()); else { it = std::find_if(begin(), end(), std::not1(std::mem_fun_ref(&Secondary::isValid))); if(it != end()) (*it).Set(skill); else push_back(skill); } }
void Dialog::SecondarySkillInfo(const std::string & header, const std::string & message, const Skill::Secondary & skill, const bool ok_button) { Display & display = Display::Get(); const ICN::icn_t system = Settings::Get().ExtGameEvilInterface() ? ICN::SYSTEME : ICN::SYSTEM; // preload AGG::PreloadObject(system); // cursor Cursor & cursor = Cursor::Get(); cursor.Hide(); cursor.SetThemes(cursor.POINTER); TextBox box1(header, Font::YELLOW_BIG, BOXAREA_WIDTH); TextBox box2(message, Font::BIG, BOXAREA_WIDTH); const Sprite & border = AGG::GetICN(ICN::SECSKILL, 15); const u8 spacer = Settings::Get().QVGA() ? 5 : 10; Box box(box1.h() + spacer + box2.h() + spacer + border.h(), ok_button); Rect pos = box.GetArea(); if(header.size()) box1.Blit(pos); pos.y += box1.h() + spacer; if(message.size()) box2.Blit(pos); pos.y += box2.h() + spacer; // blit sprite pos.x = box.GetArea().x + (pos.w - border.w()) / 2; border.Blit(pos.x, pos.y); const Sprite & sprite = AGG::GetICN(ICN::SECSKILL, skill.GetIndexSprite1()); pos.x = box.GetArea().x + (pos.w - sprite.w()) / 2; sprite.Blit(pos.x, pos.y + 3); Text text; // small text text.Set(Skill::Secondary::String(skill.Skill()), Font::SMALL); pos.x = box.GetArea().x + (pos.w - text.w()) / 2; text.Blit(pos.x, pos.y + 3); text.Set(Skill::Level::String(skill.Level())); pos.x = box.GetArea().x + (pos.w - text.w()) / 2; text.Blit(pos.x, pos.y + 55); LocalEvent & le = LocalEvent::Get(); Button *button = NULL; Point pt; if(ok_button) { pt.x = box.GetArea().x + (box.GetArea().w - AGG::GetICN(system, 1).w()) / 2; pt.y = box.GetArea().y + box.GetArea().h - AGG::GetICN(system, 1).h(); button = new Button(pt, system, 1, 2); } if(button) (*button).Draw(); cursor.Show(); display.Flip(); // message loop while(le.HandleEvents()) { if(!ok_button && !le.MousePressRight()) break; if(button) le.MousePressLeft(*button) ? button->PressDraw() : button->ReleaseDraw(); if(button && le.MouseClickLeft(*button)){ break; } if(HotKeyCloseWindow){ break; } } cursor.Hide(); if(button) delete button; }
void Dialog::SecondarySkillInfo(const Skill::Secondary & skill, const bool ok_button) { SecondarySkillInfo(skill.GetName(), skill.GetDescription(), skill, ok_button); }
bool SecondarySkillBar::QueueEventProcessing(void) { Display & display = Display::Get(); Cursor & cursor = Cursor::Get(); LocalEvent & le = LocalEvent::Get(); const Point & cu = le.GetMouseCursor(); bool modify = false; if(!(pos & cu) || !skills) return false; u8 ii = GetIndexFromCoord(cu); const Sprite & sprite_skill = AGG::GetICN((use_mini_sprite ? ICN::MINISS : ICN::SECSKILL), 0); const Rect tile(pos.x + (ii * (sprite_skill.w() + interval)), pos.y, sprite_skill.w(), sprite_skill.h()); if(ii < skills->size()) { Skill::Secondary & skill = skills->at(ii); if(skill.isValid()) { if(le.MouseClickLeft(tile)) { cursor.Hide(); Dialog::SecondarySkillInfo(skill, true); cursor.Show(); display.Flip(); } else if(le.MousePressRight(tile)) { if(can_change) { skill.Reset(); modify = true; } else { cursor.Hide(); Dialog::SecondarySkillInfo(skill, false); cursor.Show(); display.Flip(); } } } } else if(ii < MAXSECONDARYSKILL) { if(can_change && le.MouseClickLeft(tile)) { Skill::Secondary alt = Dialog::SelectSecondarySkill(); if(alt.isValid() && skills) { skills->AddSkill(alt); modify = true; } } } return modify; }