void ShowExtendedDialog(const Puzzle & pzl, const Surface & sf) { Display & display = Display::Get(); Cursor & cursor = Cursor::Get(); bool evil_interface = Settings::Get().EvilInterface(); Dialog::FrameBorder frameborder; frameborder.SetPosition((display.w() - BORDERWIDTH * 2 - sf.w()) / 2, (display.h() - sf.h() - BORDERWIDTH * 2 - 32) / 2, sf.w(), sf.h() + (Settings::Get().QVGA() ? 25 : 32)); frameborder.Redraw(); if(evil_interface) display.FillRect(80, 80, 80, frameborder.GetArea()); else display.FillRect(128, 64, 32, frameborder.GetArea()); display.Blit(sf, frameborder.GetArea()); Button buttonExit(frameborder.GetArea().x + sf.w() / 2 - 40, frameborder.GetArea().y + sf.h() + (Settings::Get().QVGA() ? 0 : 5), (evil_interface ? ICN::LGNDXTRE : ICN::LGNDXTRA), 4, 5); buttonExit.Draw(); PuzzlesDraw(pzl, sf, frameborder.GetArea().x, frameborder.GetArea().y); cursor.SetThemes(Cursor::POINTER); cursor.Show(); display.Flip(); LocalEvent & le = LocalEvent::Get(); while(le.HandleEvents()) { le.MousePressLeft(buttonExit) ? buttonExit.PressDraw() : buttonExit.ReleaseDraw(); if(le.MouseClickLeft(buttonExit) || le.KeyPress(KEY_RETURN) || le.KeyPress(KEY_ESCAPE)) break; if(Settings::Get().QVGA() && le.MouseClickLeft(frameborder.GetArea())) break; } }
void ShowStandardDialog(const Puzzle & pzl, const Surface & sf) { Display & display = Display::Get(); Cursor & cursor = Cursor::Get(); const Rect & radar_pos = Interface::Radar::Get().GetArea(); bool evil_interface = Settings::Get().EvilInterface(); Background back(BORDERWIDTH, BORDERWIDTH, sf.w(), sf.h()); back.Save(); display.Blit(AGG::GetICN((evil_interface ? ICN::EVIWPUZL : ICN::VIEWPUZL), 0), radar_pos); display.Blit(sf, BORDERWIDTH, BORDERWIDTH); Point dst_pt(radar_pos.x + 32, radar_pos.y + radar_pos.h - 37); Button buttonExit(dst_pt, (evil_interface ? ICN::LGNDXTRE : ICN::LGNDXTRA), 4, 5); buttonExit.Draw(); PuzzlesDraw(pzl, sf, BORDERWIDTH, BORDERWIDTH); cursor.SetThemes(Cursor::POINTER); cursor.Show(); display.Flip(); LocalEvent & le = LocalEvent::Get(); while(le.HandleEvents()) { le.MousePressLeft(buttonExit) ? buttonExit.PressDraw() : buttonExit.ReleaseDraw(); if(le.MouseClickLeft(buttonExit) || le.KeyPress(KEY_RETURN) || le.KeyPress(KEY_ESCAPE)) break; } Interface::Basic::Get().SetRedraw(REDRAW_RADAR); cursor.Hide(); back.Restore(); }
Dialog::answer_t PocketPC::HeroesOpenDialog(Heroes & hero, bool readonly) { Cursor & cursor = Cursor::Get(); Display & display = Display::Get(); LocalEvent & le = LocalEvent::Get(); cursor.Hide(); cursor.SetThemes(cursor.POINTER); const u16 window_w = 320; const u16 window_h = 224; Dialog::FrameBorder frameborder; frameborder.SetPosition((display.w() - window_w) / 2 - BORDERWIDTH, (display.h() - window_h) / 2 - BORDERWIDTH, window_w, window_h); frameborder.Redraw(); const Rect & dst_rt = frameborder.GetArea(); const Sprite & background = AGG::GetICN(ICN::STONEBAK, 0); const Sprite & backSprite = AGG::GetICN(ICN::SWAPWIN, 0); background.Blit(Rect(0, 0, window_w, window_h), dst_rt); // portrait AGG::GetICN(ICN::BRCREST, 6).Blit(dst_rt.x + 8, dst_rt.y, display); hero.GetPortrait50x46().Blit(dst_rt.x + 12, dst_rt.y + 4, display); // name std::string message = _("%{name} the %{race} ( Level %{level} )"); String::Replace(message, "%{name}", hero.GetName()); String::Replace(message, "%{race}", Race::String(hero.GetRace())); String::Replace(message, "%{level}", hero.GetLevel()); Text text(message, Font::SMALL); text.Blit(dst_rt.x + 73, dst_rt.y + 1); // experience ExperienceIndicator experienceInfo(hero); experienceInfo.SetPos(Point(dst_rt.x + 205, dst_rt.y + 14)); experienceInfo.Redraw(); // spell points SpellPointsIndicator spellPointsInfo(hero); spellPointsInfo.SetPos(Point(dst_rt.x + 238, dst_rt.y + 16)); spellPointsInfo.Redraw(); // morale MoraleIndicator moraleIndicator(hero); moraleIndicator.SetPos(Point(dst_rt.x + 280, dst_rt.y + 20)); moraleIndicator.Redraw(); // luck LuckIndicator luckIndicator(hero); luckIndicator.SetPos(Point(dst_rt.x + 280, dst_rt.y + 60)); luckIndicator.Redraw(); // prim skill const Rect ras(dst_rt.x + 74, dst_rt.y + 14, 34, 34); backSprite.Blit(Rect(216, 51, ras.w, ras.h), ras); text.Set(GetString(hero.GetAttack())); text.Blit(dst_rt.x + 74 + (34 - text.w()) / 2, dst_rt.y + 47); const Rect rds(dst_rt.x + 107, dst_rt.y + 14, 34, 34); backSprite.Blit(Rect(216, 84, rds.w, rds.h), rds); text.Set(GetString(hero.GetDefense())); text.Blit(dst_rt.x + 107 + (34 - text.w()) / 2, dst_rt.y + 47); const Rect rps(dst_rt.x + 140, dst_rt.y + 14, 34, 34); backSprite.Blit(Rect(216, 117, rps.w, rps.h), rps); text.Set(GetString(hero.GetPower())); text.Blit(dst_rt.x + 140 + (34 - text.w()) / 2, dst_rt.y + 47); const Rect rks(dst_rt.x + 173, dst_rt.y + 14, 34, 34); backSprite.Blit(Rect(216, 150, rks.w, rks.h), rks); text.Set(GetString(hero.GetKnowledge())); text.Blit(dst_rt.x + 173 + (34 - text.w()) / 2, dst_rt.y + 47); // sec skill backSprite.Blit(Rect(21, 198, 267, 36), dst_rt.x + 7, dst_rt.y + 57); // secondary skill SecondarySkillBar secskill_bar; secskill_bar.SetPos(dst_rt.x + 9, dst_rt.y + 59); secskill_bar.SetUseMiniSprite(); secskill_bar.SetInterval(1); secskill_bar.SetSkills(hero.GetSecondarySkills()); secskill_bar.Redraw(); // army bar const Rect rt1(36, 267, 43, 53); Surface sfb1(rt1.w, rt1.h); backSprite.Blit(rt1, 0, 0, sfb1); Surface sfc1(rt1.w, rt1.h - 10); Cursor::DrawCursor(sfc1, 0xd6, true); SelectArmyBar selectArmy; selectArmy.SetArmy(hero.GetArmy()); selectArmy.SetPos(dst_rt.x + 50, dst_rt.y + 170); selectArmy.SetInterval(2); selectArmy.SetBackgroundSprite(sfb1); selectArmy.SetCursorSprite(sfc1); selectArmy.SetUseMons32Sprite(); selectArmy.SetSaveLastTroop(); if(readonly) selectArmy.SetReadOnly(); const Castle* castle = hero.inCastle(); if(castle) selectArmy.SetCastle(*castle); selectArmy.Redraw(); // art bar const Rect rt2(23, 347, 34, 34); Surface sfb2(rt2.w, rt2.h); backSprite.Blit(rt2, 0, 0, sfb2); Surface sfc2(rt2.w, rt2.h); Cursor::DrawCursor(sfc2, 0xd6, true); SelectArtifactsBar selectArtifacts(hero); selectArtifacts.SetPos(dst_rt.x + 37, dst_rt.y + 95); selectArtifacts.SetInterval(2); selectArtifacts.SetBackgroundSprite(sfb2); selectArtifacts.SetCursorSprite(sfc2); selectArtifacts.SetUseArts32Sprite(); if(readonly) selectArtifacts.SetReadOnly(); selectArtifacts.Redraw(); Button buttonDismiss(dst_rt.x + dst_rt.w / 2 - 160, dst_rt.y + dst_rt.h - 125, ICN::HSBTNS, 0, 1); Button buttonExit(dst_rt.x + dst_rt.w / 2 + 130, dst_rt.y + dst_rt.h - 125, ICN::HSBTNS, 2, 3); Button buttonPrev(dst_rt.x + 34, dst_rt.y + 200, ICN::TRADPOST, 3, 4); Button buttonNext(dst_rt.x + 275, dst_rt.y + 200, ICN::TRADPOST, 5, 6); if(castle || readonly) { buttonDismiss.Press(); buttonDismiss.SetDisable(true); } if(readonly || 2 > world.GetKingdom(hero.GetColor()).GetHeroes().size()) { buttonNext.Press(); buttonPrev.Press(); buttonNext.SetDisable(true); buttonPrev.SetDisable(true); } buttonDismiss.Draw(); buttonExit.Draw(); buttonNext.Draw(); buttonPrev.Draw(); cursor.Show(); display.Flip(); while(le.HandleEvents()) { le.MousePressLeft(buttonNext) ? buttonNext.PressDraw() : buttonNext.ReleaseDraw(); le.MousePressLeft(buttonPrev) ? buttonPrev.PressDraw() : buttonPrev.ReleaseDraw(); le.MousePressLeft(buttonExit) ? buttonExit.PressDraw() : buttonExit.ReleaseDraw(); if(buttonDismiss.isEnable()) le.MousePressLeft(buttonDismiss) ? buttonDismiss.PressDraw() : buttonDismiss.ReleaseDraw(); if(buttonNext.isEnable() && le.MouseClickLeft(buttonNext)) return Dialog::NEXT; else if(buttonPrev.isEnable() && le.MouseClickLeft(buttonPrev)) return Dialog::PREV; else // exit if(le.MouseClickLeft(buttonExit) || Game::HotKeyPress(Game::EVENT_DEFAULT_EXIT)) return Dialog::CANCEL; else // dismiss if(buttonDismiss.isEnable() && le.MouseClickLeft(buttonDismiss) && Dialog::YES == Dialog::Message(hero.GetName(), _("Are you sure you want to dismiss this Hero?"), Font::BIG, Dialog::YES | Dialog::NO)) { return Dialog::DISMISS; } // primary click info if(le.MouseClickLeft(ras)) Dialog::Message(_("Attack Skill"), _("Your attack skill is a bonus added to each creature's attack skill."), Font::BIG, Dialog::OK); else if(le.MouseClickLeft(rds)) Dialog::Message(_("Defense Skill"), _("Your defense skill is a bonus added to each creature's defense skill."), Font::BIG, Dialog::OK); else if(le.MouseClickLeft(rps)) Dialog::Message(_("Spell Power"), _("Your spell power determines the length or power of a spell."), Font::BIG, Dialog::OK); else if(le.MouseClickLeft(rks)) Dialog::Message(_("Knowledge"), _("Your knowledge determines how many spell points your hero may have. Under normal cirumstances, a hero is limited to 10 spell points per level of knowledge."), Font::BIG, Dialog::OK); if(le.MouseCursor(secskill_bar.GetArea())) secskill_bar.QueueEventProcessing(); // selector troops event if(le.MouseCursor(selectArmy.GetArea())) { if(selectArtifacts.isSelected()) selectArtifacts.Reset(); if(SelectArmyBar::QueueEventProcessing(selectArmy)) { cursor.Hide(); moraleIndicator.Redraw(); luckIndicator.Redraw(); cursor.Show(); display.Flip(); } } // selector artifacts event if(le.MouseCursor(selectArtifacts.GetArea())) { if(selectArmy.isSelected()) selectArmy.Reset(); SelectArtifactsBar::QueueEventProcessing(selectArtifacts); } if(le.MouseCursor(moraleIndicator.GetArea())) MoraleIndicator::QueueEventProcessing(moraleIndicator); else if(le.MouseCursor(luckIndicator.GetArea())) LuckIndicator::QueueEventProcessing(luckIndicator); else if(le.MouseCursor(experienceInfo.GetArea())) experienceInfo.QueueEventProcessing(); else if(le.MouseCursor(spellPointsInfo.GetArea())) spellPointsInfo.QueueEventProcessing(); } return Dialog::ZERO; }
void Castle::OpenWell(void) { const Settings & conf = Settings::Get(); Display & display = Display::Get(); // cursor Cursor & cursor = Cursor::Get(); cursor.Hide(); Dialog::FrameBorder frameborder; frameborder.SetPosition((display.w() - 640 - BORDERWIDTH * 2) / 2, (display.h() - 480 - BORDERWIDTH * 2) / 2, 640, 480); frameborder.Redraw(); const Point cur_pt(frameborder.GetArea().x, frameborder.GetArea().y); Point dst_pt(cur_pt); // button exit dst_pt.x = cur_pt.x + 578; dst_pt.y = cur_pt.y + 461; Button buttonExit(dst_pt, ICN::WELLXTRA, 0, 1); dst_pt.x = cur_pt.x; dst_pt.y = cur_pt.y + 461; Button buttonMax(dst_pt, ICN::BUYMAX, 0, 1); const Rect rectMonster1(cur_pt.x + 20, cur_pt.y + 18, 288, 124); const Rect rectMonster2(cur_pt.x + 20, cur_pt.y + 168, 288, 124); const Rect rectMonster3(cur_pt.x + 20, cur_pt.y + 318, 288, 124); const Rect rectMonster4(cur_pt.x + 334, cur_pt.y + 18, 288, 124); const Rect rectMonster5(cur_pt.x + 334, cur_pt.y + 168, 288, 124); const Rect rectMonster6(cur_pt.x + 334, cur_pt.y + 318, 288, 124); buttonExit.Draw(); WellRedrawInfoArea(cur_pt); if(! conf.ExtCastleAllowBuyFromWell()) buttonMax.SetDisable(true); else { buttonMax.Draw(); } std::vector<u32> alldwellings; alldwellings.reserve(6); alldwellings.push_back(DWELLING_MONSTER6); alldwellings.push_back(DWELLING_MONSTER5); alldwellings.push_back(DWELLING_MONSTER4); alldwellings.push_back(DWELLING_MONSTER3); alldwellings.push_back(DWELLING_MONSTER2); alldwellings.push_back(DWELLING_MONSTER1); cursor.Show(); display.Flip(); bool redraw = false; LocalEvent & le = LocalEvent::Get(); // loop while(le.HandleEvents()) { le.MousePressLeft(buttonExit) ? buttonExit.PressDraw() : buttonExit.ReleaseDraw(); buttonMax.isEnable() && le.MousePressLeft(buttonMax) ? buttonMax.PressDraw() : buttonMax.ReleaseDraw(); if(le.MouseClickLeft(buttonExit) || HotKeyCloseWindow) break; // extended version (click - buy dialog monster) if(conf.ExtCastleAllowBuyFromWell()) { if(buttonMax.isEnable() && le.MouseClickLeft(buttonMax)) { dwellings_t results; Funds cur, total; u16 can_recruit; std::string str; for(std::vector<u32>::const_iterator it = alldwellings.begin(); it != alldwellings.end(); ++it) if(0 != (can_recruit = HowManyRecruitMonster(*this, *it, total, cur))) { results.push_back(dwelling_t(*it, can_recruit)); total += cur; const Monster ms(race, GetActualDwelling(*it)); str.append(ms.GetPluralName(can_recruit)); str.append(" - "); str.append(GetString(can_recruit)); str.append("\n"); } if(str.empty()) str = "None"; if(Dialog::YES == Dialog::ResourceInfo(_("Buy Monsters:"), str, total, Dialog::YES|Dialog::NO)) { for(dwellings_t::const_iterator it = results.begin(); it != results.end(); ++it) { const dwelling_t & dw = *it; RecruitMonster(dw.first, dw.second); } redraw = true; } } if(building & DWELLING_MONSTER1 && dwelling[0] && le.MouseClickLeft(rectMonster1) && RecruitMonster(DWELLING_MONSTER1, Dialog::RecruitMonster( Monster(race, DWELLING_MONSTER1), dwelling[0]))) redraw = true; else if(building & DWELLING_MONSTER2 && dwelling[1] && le.MouseClickLeft(rectMonster2) && RecruitMonster(DWELLING_MONSTER2, Dialog::RecruitMonster( Monster(race, GetActualDwelling(DWELLING_MONSTER2)), dwelling[1]))) redraw = true; else if(building & DWELLING_MONSTER3 && dwelling[2] && le.MouseClickLeft(rectMonster3) && RecruitMonster(DWELLING_MONSTER3, Dialog::RecruitMonster( Monster(race, GetActualDwelling(DWELLING_MONSTER3)), dwelling[2]))) redraw = true; else if(building & DWELLING_MONSTER4 && dwelling[3] && le.MouseClickLeft(rectMonster4) && RecruitMonster(DWELLING_MONSTER4, Dialog::RecruitMonster( Monster(race, GetActualDwelling(DWELLING_MONSTER4)), dwelling[3]))) redraw = true; else if(building & DWELLING_MONSTER5 && dwelling[4] && le.MouseClickLeft(rectMonster5) && RecruitMonster(DWELLING_MONSTER5, Dialog::RecruitMonster( Monster(race, GetActualDwelling(DWELLING_MONSTER5)), dwelling[4]))) redraw = true; else if(building & DWELLING_MONSTER6 && dwelling[5] && le.MouseClickLeft(rectMonster6) && RecruitMonster(DWELLING_MONSTER6, Dialog::RecruitMonster( Monster(race, GetActualDwelling(DWELLING_MONSTER6)), dwelling[5]))) redraw = true; if(redraw) { cursor.Hide(); WellRedrawInfoArea(cur_pt); buttonMax.Draw(); cursor.Show(); display.Flip(); redraw = false; } } } }
void Heroes::MeetingDialog(Heroes & heroes2) { if(Settings::Get().QVGA()) return PocketPC::HeroesMeeting(*this, heroes2); Display & display = Display::Get(); // cursor Cursor & cursor = Cursor::Get(); cursor.Hide(); cursor.SetThemes(cursor.POINTER); const Sprite &backSprite = AGG::GetICN(ICN::SWAPWIN, 0); const Point cur_pt((display.w() - backSprite.w()) / 2, (display.h() - backSprite.h()) / 2); SpriteBack background(Rect(cur_pt, backSprite.w(), backSprite.h())); Point dst_pt(cur_pt); std::string message; Rect src_rt(0, 0, 640, 480); // background dst_pt.x = cur_pt.x; dst_pt.y = cur_pt.y; backSprite.Blit(src_rt, dst_pt); // header message = _("%{name1} meets %{name2}"); StringReplace(message, "%{name1}", GetName()); StringReplace(message, "%{name2}", heroes2.GetName()); Text text(message, Font::BIG); text.Blit(cur_pt.x + 320 - text.w() / 2, cur_pt.y + 26); // portrait dst_pt.x = cur_pt.x + 93; dst_pt.y = cur_pt.y + 72; PortraitRedraw(dst_pt.x, dst_pt.y, PORT_BIG, display); dst_pt.x = cur_pt.x + 445; dst_pt.y = cur_pt.y + 72; heroes2.PortraitRedraw(dst_pt.x, dst_pt.y, PORT_BIG, display); dst_pt.x = cur_pt.x + 34; dst_pt.y = cur_pt.y + 75; MoraleIndicator moraleIndicator1(*this); moraleIndicator1.SetPos(dst_pt); moraleIndicator1.Redraw(); dst_pt.x = cur_pt.x + 34; dst_pt.y = cur_pt.y + 115; LuckIndicator luckIndicator1(*this); luckIndicator1.SetPos(dst_pt); luckIndicator1.Redraw(); dst_pt.x = cur_pt.x + 566; dst_pt.y = cur_pt.y + 75; MoraleIndicator moraleIndicator2(heroes2); moraleIndicator2.SetPos(dst_pt); moraleIndicator2.Redraw(); dst_pt.x = cur_pt.x + 566; dst_pt.y = cur_pt.y + 115; LuckIndicator luckIndicator2(heroes2); luckIndicator2.SetPos(dst_pt); luckIndicator2.Redraw(); // primary skill SpriteBack backPrimary(Rect(cur_pt.x + 255, cur_pt.y + 50, 130, 135)); PrimarySkillsBar primskill_bar1(this, true); primskill_bar1.SetColRows(1, 4); primskill_bar1.SetVSpace(-1); primskill_bar1.SetTextOff(70, -25); primskill_bar1.SetPos(cur_pt.x + 216, cur_pt.y + 51); PrimarySkillsBar primskill_bar2(&heroes2, true); primskill_bar2.SetColRows(1, 4); primskill_bar2.SetVSpace(-1); primskill_bar2.SetTextOff(-70, -25); primskill_bar2.SetPos(cur_pt.x + 389, cur_pt.y + 51); RedrawPrimarySkillInfo(cur_pt, &primskill_bar1, &primskill_bar2); // secondary skill SecondarySkillsBar secskill_bar1; secskill_bar1.SetColRows(8, 1); secskill_bar1.SetHSpace(-1); secskill_bar1.SetContent(secondary_skills); secskill_bar1.SetPos(cur_pt.x + 22, cur_pt.y + 199); secskill_bar1.Redraw(); SecondarySkillsBar secskill_bar2; secskill_bar2.SetColRows(8, 1); secskill_bar2.SetHSpace(-1); secskill_bar2.SetContent(heroes2.GetSecondarySkills()); secskill_bar2.SetPos(cur_pt.x + 353, cur_pt.y + 199); secskill_bar2.Redraw(); // army dst_pt.x = cur_pt.x + 36; dst_pt.y = cur_pt.y + 267; ArmyBar selectArmy1(&GetArmy(), true, false); selectArmy1.SetColRows(5, 1); selectArmy1.SetPos(dst_pt.x, dst_pt.y); selectArmy1.SetHSpace(2); selectArmy1.Redraw(); dst_pt.x = cur_pt.x + 381; dst_pt.y = cur_pt.y + 267; ArmyBar selectArmy2(&heroes2.GetArmy(), true, false); selectArmy2.SetColRows(5, 1); selectArmy2.SetPos(dst_pt.x, dst_pt.y); selectArmy2.SetHSpace(2); selectArmy2.Redraw(); // artifact dst_pt.x = cur_pt.x + 23; dst_pt.y = cur_pt.y + 347; ArtifactsBar selectArtifacts1(this, true, false); selectArtifacts1.SetColRows(7, 2); selectArtifacts1.SetHSpace(2); selectArtifacts1.SetVSpace(2); selectArtifacts1.SetContent(GetBagArtifacts()); selectArtifacts1.SetPos(dst_pt.x, dst_pt.y); selectArtifacts1.Redraw(); dst_pt.x = cur_pt.x + 367; dst_pt.y = cur_pt.y + 347; ArtifactsBar selectArtifacts2(&heroes2, true, false); selectArtifacts2.SetColRows(7, 2); selectArtifacts2.SetHSpace(2); selectArtifacts2.SetVSpace(2); selectArtifacts2.SetContent(heroes2.GetBagArtifacts()); selectArtifacts2.SetPos(dst_pt.x, dst_pt.y); selectArtifacts2.Redraw(); // button exit dst_pt.x = cur_pt.x + 280; dst_pt.y = cur_pt.y + 428; Button buttonExit(dst_pt.x, dst_pt.y, ICN::SWAPBTN, 0, 1); buttonExit.Draw(); cursor.Show(); display.Flip(); MovePointsScaleFixed(); heroes2.MovePointsScaleFixed(); // scholar action if(Settings::Get().ExtWorldEyeEagleAsScholar()) Heroes::ScholarAction(*this, heroes2); LocalEvent & le = LocalEvent::Get(); // message loop while(le.HandleEvents()) { le.MousePressLeft(buttonExit) ? buttonExit.PressDraw() : buttonExit.ReleaseDraw(); if(le.MouseClickLeft(buttonExit) || HotKeyCloseWindow) break; // selector troops event if((le.MouseCursor(selectArmy1.GetArea()) && selectArmy1.QueueEventProcessing(selectArmy2)) || (le.MouseCursor(selectArmy2.GetArea()) && selectArmy2.QueueEventProcessing(selectArmy1))) { cursor.Hide(); if(selectArtifacts1.isSelected()) selectArtifacts1.ResetSelected(); else if(selectArtifacts2.isSelected()) selectArtifacts2.ResetSelected(); selectArmy1.Redraw(); selectArmy2.Redraw(); moraleIndicator1.Redraw(); moraleIndicator2.Redraw(); luckIndicator1.Redraw(); luckIndicator2.Redraw(); cursor.Show(); display.Flip(); } // selector artifacts event if((le.MouseCursor(selectArtifacts1.GetArea()) && selectArtifacts1.QueueEventProcessing(selectArtifacts2)) || (le.MouseCursor(selectArtifacts2.GetArea()) && selectArtifacts2.QueueEventProcessing(selectArtifacts1))) { cursor.Hide(); if(selectArmy1.isSelected()) selectArmy1.ResetSelected(); else if(selectArmy2.isSelected()) selectArmy2.ResetSelected(); selectArtifacts1.Redraw(); selectArtifacts2.Redraw(); backPrimary.Restore(); RedrawPrimarySkillInfo(cur_pt, &primskill_bar1, &primskill_bar2); moraleIndicator1.Redraw(); moraleIndicator2.Redraw(); luckIndicator1.Redraw(); luckIndicator2.Redraw(); cursor.Show(); display.Flip(); } if((le.MouseCursor(primskill_bar1.GetArea()) && primskill_bar1.QueueEventProcessing()) || (le.MouseCursor(primskill_bar2.GetArea()) && primskill_bar2.QueueEventProcessing()) || (le.MouseCursor(secskill_bar1.GetArea()) && secskill_bar1.QueueEventProcessing()) || (le.MouseCursor(secskill_bar2.GetArea()) && secskill_bar2.QueueEventProcessing())) { cursor.Show(); display.Flip(); } if(le.MouseCursor(moraleIndicator1.GetArea())) MoraleIndicator::QueueEventProcessing(moraleIndicator1); else if(le.MouseCursor(moraleIndicator2.GetArea())) MoraleIndicator::QueueEventProcessing(moraleIndicator2); else if(le.MouseCursor(luckIndicator1.GetArea())) LuckIndicator::QueueEventProcessing(luckIndicator1); else if(le.MouseCursor(luckIndicator2.GetArea())) LuckIndicator::QueueEventProcessing(luckIndicator2); } if(Settings::Get().ExtHeroRecalculateMovement()) { RecalculateMovePoints(); heroes2.RecalculateMovePoints(); } cursor.Hide(); background.Restore(); cursor.Show(); display.Flip(); }
void Kingdom::OverviewDialog(void) { Display & display = Display::Get(); Cursor & cursor = Cursor::Get(); cursor.Hide(); cursor.SetThemes(cursor.POINTER); Dialog::FrameBorder background; background.SetPosition((display.w() - 640 - BORDERWIDTH * 2) / 2, (display.h() - 480 - BORDERWIDTH * 2) / 2, 640, 480); background.Redraw(); const Point cur_pt(background.GetArea().x, background.GetArea().y); Point dst_pt(cur_pt); AGG::GetICN(ICN::STONEBAK, 0).Blit(dst_pt); AGG::GetICN(ICN::OVERBACK, 0).Blit(dst_pt); RedrawIncomeInfo(cur_pt, *this); StatsHeroesList listHeroes(dst_pt, heroes); StatsCastlesList listCastles(dst_pt, castles); // buttons dst_pt.x = cur_pt.x + 540; dst_pt.y = cur_pt.y + 360; Button buttonHeroes(dst_pt, ICN::OVERVIEW, 0, 1); dst_pt.x = cur_pt.x + 540; dst_pt.y = cur_pt.y + 405; Button buttonCastle(dst_pt, ICN::OVERVIEW, 2, 3); dst_pt.x = cur_pt.x + 540; dst_pt.y = cur_pt.y + 453; Button buttonExit(dst_pt, ICN::OVERVIEW, 4, 5); // set state view: heroes buttonHeroes.Press(); buttonCastle.Release(); Interface::ListBasic* listStats = &listHeroes; listStats->Redraw(); buttonHeroes.Draw(); buttonCastle.Draw(); buttonExit.Draw(); cursor.Show(); display.Flip(); LocalEvent & le = LocalEvent::Get(); // dialog menu loop while(le.HandleEvents()) { le.MousePressLeft(buttonExit) ? buttonExit.PressDraw() : buttonExit.ReleaseDraw(); // switch view: heroes/castle if(buttonHeroes.isReleased() && le.MouseClickLeft(buttonHeroes)) { cursor.Hide(); buttonHeroes.Press(); buttonCastle.Release(); buttonHeroes.Draw(); buttonCastle.Draw(); listStats = &listHeroes; } else if(buttonCastle.isReleased() && le.MouseClickLeft(buttonCastle)) { cursor.Hide(); buttonCastle.Press(); buttonHeroes.Release(); buttonHeroes.Draw(); buttonCastle.Draw(); listStats = &listCastles; } // exit event if(le.MouseClickLeft(buttonExit) || Game::HotKeyPress(Game::EVENT_DEFAULT_EXIT)) break; listStats->QueueEventProcessing(); // redraw if(! cursor.isVisible()) { listStats->Redraw(); cursor.Show(); display.Flip(); } } }
int Dialog::ArmyInfo(const Troop & troop, int flags) { if(Settings::Get().QVGA()) return PocketPC::DialogArmyInfo(troop, flags); Display & display = Display::Get(); const int viewarmy = Settings::Get().ExtGameEvilInterface() ? ICN::VIEWARME : ICN::VIEWARMY; const Surface & sprite_dialog = AGG::GetICN(viewarmy, 0); Cursor & cursor = Cursor::Get(); cursor.Hide(); cursor.SetThemes(cursor.POINTER); SpriteBack back(Rect((display.w() - sprite_dialog.w()) / 2, (display.h() - sprite_dialog.h()) / 2, sprite_dialog.w(), sprite_dialog.h())); const Rect & pos_rt = back.GetArea(); sprite_dialog.Blit(pos_rt.x, pos_rt.y, display); Point dst_pt; Text text; dst_pt.x = pos_rt.x + 400; dst_pt.y = pos_rt.y + 40; DrawMonsterStats(dst_pt, troop); if(troop.isBattle()) { dst_pt.x = pos_rt.x + 400; dst_pt.y = pos_rt.y + 205; DrawBattleStats(dst_pt, troop); } // name text.Set(troop.GetName(), Font::BIG); dst_pt.x = pos_rt.x + 140 - text.w() / 2; dst_pt.y = pos_rt.y + 40; text.Blit(dst_pt); // count text.Set(GetString(troop.GetCount())); dst_pt.x = pos_rt.x + 140 - text.w() / 2; dst_pt.y = pos_rt.y + 225; text.Blit(dst_pt); const Sprite & frame = AGG::GetICN(troop.ICNMonh(), 0); frame.Blit(pos_rt.x + (pos_rt.w / 2 - frame.w()) / 2, pos_rt.y + 180 - frame.h()); // button upgrade dst_pt.x = pos_rt.x + 284; dst_pt.y = pos_rt.y + 190; Button buttonUpgrade(dst_pt.x, dst_pt.y, viewarmy, 5, 6); // button dismiss dst_pt.x = pos_rt.x + 284; dst_pt.y = pos_rt.y + 222; Button buttonDismiss(dst_pt.x, dst_pt.y, viewarmy, 1, 2); // button exit dst_pt.x = pos_rt.x + 415; dst_pt.y = pos_rt.y + 225; Button buttonExit(dst_pt.x, dst_pt.y, viewarmy, 3, 4); if(READONLY & flags) { buttonDismiss.Press(); buttonDismiss.SetDisable(true); } if(!troop.isBattle() && troop.isAllowUpgrade()) { if(UPGRADE & flags) { if(UPGRADE_DISABLE & flags) { buttonUpgrade.Press(); buttonUpgrade.SetDisable(true); } else buttonUpgrade.SetDisable(false); buttonUpgrade.Draw(); } else buttonUpgrade.SetDisable(true); } else buttonUpgrade.SetDisable(true); if(BUTTONS & flags) { if(!troop.isBattle()) buttonDismiss.Draw(); buttonExit.Draw(); } LocalEvent & le = LocalEvent::Get(); int result = Dialog::ZERO; cursor.Show(); display.Flip(); // dialog menu loop while(le.HandleEvents()) { if(flags & BUTTONS) { if(buttonUpgrade.isEnable()) le.MousePressLeft(buttonUpgrade) ? (buttonUpgrade).PressDraw() : (buttonUpgrade).ReleaseDraw(); if(buttonDismiss.isEnable()) le.MousePressLeft(buttonDismiss) ? (buttonDismiss).PressDraw() : (buttonDismiss).ReleaseDraw(); le.MousePressLeft(buttonExit) ? (buttonExit).PressDraw() : (buttonExit).ReleaseDraw(); // upgrade if(buttonUpgrade.isEnable() && le.MouseClickLeft(buttonUpgrade)) { std::string msg = 1.0f != Monster::GetUpgradeRatio() ? _("Your troops can be upgraded, but it will cost you %{ratio} times the difference in cost for each troop, rounded up to next highest number. Do you wish to upgrade them?") : _("Your troops can be upgraded, but it will cost you dearly. Do you wish to upgrade them?"); StringReplace(msg, "%{ratio}", GetString(Monster::GetUpgradeRatio(), 2)); if(Dialog::YES == Dialog::ResourceInfo("", msg, troop.GetUpgradeCost(), Dialog::YES|Dialog::NO)) { result = Dialog::UPGRADE; break; } } else // dismiss if(buttonDismiss.isEnable() && le.MouseClickLeft(buttonDismiss) && Dialog::YES == Dialog::Message("", _("Are you sure you want to dismiss this army?"), Font::BIG, Dialog::YES | Dialog::NO)) { result = Dialog::DISMISS; break; } else // exit if(le.MouseClickLeft(buttonExit) || Game::HotKeyPressEvent(Game::EVENT_DEFAULT_EXIT)){ result = Dialog::CANCEL; break; } } else { if(!le.MousePressRight()) break; } } cursor.Hide(); back.Restore(); return result; }
/* readonly: false, fade: false */ Dialog::answer_t Heroes::OpenDialog(bool readonly, bool fade) { if(Settings::Get().QVGA()) return PocketPC::HeroesOpenDialog(*this, readonly); Display & display = Display::Get(); Cursor & cursor = Cursor::Get(); cursor.Hide(); cursor.SetThemes(cursor.POINTER); Dialog::FrameBorder background; background.SetPosition((display.w() - 640 - BORDERWIDTH * 2) / 2, (display.h() - 480 - BORDERWIDTH * 2) / 2, 640, 480); background.Redraw(); const Point cur_pt(background.GetArea().x, background.GetArea().y); Point dst_pt(cur_pt); // fade if(fade && Settings::Get().ExtGameUseFade()) display.Fade(); display.FillRect(0, 0, 0, Rect(dst_pt, 640, 480)); AGG::GetICN(ICN::HEROBKG, 0).Blit(dst_pt); AGG::GetICN(Settings::Get().ExtGameEvilInterface() ? ICN::HEROEXTE : ICN::HEROEXTG, 0).Blit(dst_pt); std::string message; // portrait dst_pt.x = cur_pt.x + 49; dst_pt.y = cur_pt.y + 31; GetPortrait101x93().Blit(dst_pt, display); // name message = _("%{name} the %{race} ( Level %{level} )"); String::Replace(message, "%{name}", name); String::Replace(message, "%{race}", Race::String(race)); String::Replace(message, "%{level}", GetLevel()); Text text(message, Font::BIG); text.Blit(cur_pt.x + 320 - text.w() / 2, cur_pt.y + 1); // attack text.Set(_("Attack Skill"), Font::SMALL); dst_pt.x = cur_pt.x + 196; dst_pt.y = cur_pt.y + 34; text.Blit(dst_pt.x - text.w() / 2, dst_pt.y); text.Set(GetString(GetAttack()), Font::BIG); dst_pt.y += 70; text.Blit(dst_pt.x - text.w() / 2, dst_pt.y); const Rect rectAttackSkill(cur_pt.x + 156, cur_pt.y + 30, 80, 92); std::string attackDescription(_("Your attack skill is a bonus added to each creature's attack skill.")); message.clear(); GetAttack(&message); if(message.size()) { attackDescription.append("\n \n"); attackDescription.append(_("Current Modifiers:")); attackDescription.append("\n \n"); attackDescription.append(message); } // defense dst_pt.x = cur_pt.x + 284; dst_pt.y = cur_pt.y + 34; text.Set(_("Defense Skill"), Font::SMALL); text.Blit(dst_pt.x - text.w() / 2, dst_pt.y); dst_pt.y += 70; text.Set(GetString(GetDefense()), Font::BIG); text.Blit(dst_pt.x - text.w() / 2, dst_pt.y); const Rect rectDefenseSkill(cur_pt.x + 156 + 88, cur_pt.y + 30, 80, 92); std::string defenseDescription(_("Your defense skill is a bonus added to each creature's defense skill.")); message.clear(); GetDefense(&message); if(message.size()) { defenseDescription.append("\n \n"); defenseDescription.append(_("Current Modifiers:")); defenseDescription.append("\n \n"); defenseDescription.append(message); } // spell dst_pt.x = cur_pt.x + 372; dst_pt.y = cur_pt.y + 34; text.Set(_("Spell Power"), Font::SMALL); text.Blit(dst_pt.x - text.w() / 2, dst_pt.y); dst_pt.y += 70; text.Set(GetString(GetPower()), Font::BIG); text.Blit(dst_pt.x - text.w() / 2, dst_pt.y); const Rect rectSpellSkill(cur_pt.x + 156 + 2 * 88, cur_pt.y + 30, 80, 92); std::string powerDescription(_("Your spell power determines the length or power of a spell.")); message.clear(); GetPower(&message); if(message.size()) { powerDescription.append("\n \n"); powerDescription.append(_("Current Modifiers:")); powerDescription.append("\n \n"); powerDescription.append(message); } // knowledge dst_pt.x = cur_pt.x + 460; dst_pt.y = cur_pt.y + 34; text.Set(_("Knowledge"), Font::SMALL); text.Blit(dst_pt.x - text.w() / 2, dst_pt.y); dst_pt.y += 70; text.Set(GetString(GetKnowledge()), Font::BIG); text.Blit(dst_pt.x - text.w() / 2, dst_pt.y); const Rect rectKnowledgeSkill(cur_pt.x + 156 + 3 * 88, cur_pt.y + 30, 80, 92); std::string knowledgeDescription(_("Your knowledge determines how many spell points your hero may have. Under normal cirumstances, a hero is limited to 10 spell points per level of knowledge.")); message.clear(); GetKnowledge(&message); if(message.size()) { knowledgeDescription.append("\n \n"); knowledgeDescription.append(_("Current Modifiers:")); knowledgeDescription.append("\n \n"); knowledgeDescription.append(message); } // morale dst_pt.x = cur_pt.x + 514; dst_pt.y = cur_pt.y + 35; MoraleIndicator moraleIndicator(*this); moraleIndicator.SetPos(dst_pt); moraleIndicator.Redraw(); // luck dst_pt.x = cur_pt.x + 552; dst_pt.y = cur_pt.y + 35; LuckIndicator luckIndicator(*this); luckIndicator.SetPos(dst_pt); luckIndicator.Redraw(); // army format spread dst_pt.x = cur_pt.x + 515; dst_pt.y = cur_pt.y + 63; const Sprite & sprite1 = AGG::GetICN(ICN::HSICONS, 9); sprite1.Blit(dst_pt); const Rect rectSpreadArmyFormat(dst_pt, sprite1.w(), sprite1.h()); const std::string descriptionSpreadArmyFormat = _("'Spread' combat formation spreads your armies from the top to the bottom of the battlefield, with at least one empty space between each army."); const Point army1_pt(dst_pt.x - 1, dst_pt.y - 1); // army format grouped dst_pt.x = cur_pt.x + 552; dst_pt.y = cur_pt.y + 63; const Sprite & sprite2 = AGG::GetICN(ICN::HSICONS, 10); sprite2.Blit(dst_pt); const Rect rectGroupedArmyFormat(dst_pt, sprite2.w(), sprite2.h()); const std::string descriptionGroupedArmyFormat = _("'Grouped' combat formation bunches your army together in the center of your side of the battlefield."); const Point army2_pt(dst_pt.x - 1, dst_pt.y - 1); // cursor format SpriteCursor cursorFormat(AGG::GetICN(ICN::HSICONS, 11), Army::FORMAT_SPREAD == army.GetCombatFormat() ? army1_pt : army2_pt); cursorFormat.Show(Army::FORMAT_SPREAD == army.GetCombatFormat() ? army1_pt : army2_pt); // experience ExperienceIndicator experienceInfo(*this); experienceInfo.SetPos(Point(cur_pt.x + 514, cur_pt.y + 85)); experienceInfo.Redraw(); // spell points SpellPointsIndicator spellPointsInfo(*this); spellPointsInfo.SetPos(Point(cur_pt.x + 549, cur_pt.y + 87)); spellPointsInfo.Redraw(); // crest dst_pt.x = cur_pt.x + 49; dst_pt.y = cur_pt.y + 130; AGG::GetICN(ICN::CREST, Color::NONE == color ? Color::GetIndex(Settings::Get().CurrentColor()) : Color::GetIndex(color)).Blit(dst_pt); // monster dst_pt.x = cur_pt.x + 156; dst_pt.y = cur_pt.y + 130; SelectArmyBar selectArmy; selectArmy.SetArmy(army); selectArmy.SetPos(dst_pt); selectArmy.SetInterval(6); selectArmy.SetBackgroundSprite(AGG::GetICN(ICN::STRIP, 2)); selectArmy.SetCursorSprite(AGG::GetICN(ICN::STRIP, 1)); selectArmy.SetSaveLastTroop(); if(readonly) selectArmy.SetReadOnly(); const Castle* castle = inCastle(); if(castle) selectArmy.SetCastle(*castle); selectArmy.Redraw(); // secskill SecondarySkillBar secskill_bar; secskill_bar.SetPos(cur_pt.x + 3, cur_pt.y + 233); secskill_bar.SetInterval(5); secskill_bar.SetSkills(secondary_skills); secskill_bar.Redraw(); dst_pt.x = cur_pt.x + 51; dst_pt.y = cur_pt.y + 308; SelectArtifactsBar selectArtifacts(*this); selectArtifacts.SetPos(dst_pt); selectArtifacts.SetInterval(15); selectArtifacts.SetBackgroundSprite(AGG::GetICN(ICN::ARTIFACT, 0)); selectArtifacts.SetCursorSprite(AGG::GetICN(ICN::NGEXTRA, 62)); if(readonly) selectArtifacts.SetReadOnly(); selectArtifacts.Redraw(); // bottom small bar dst_pt.x = cur_pt.x + 22; dst_pt.y = cur_pt.y + 460; const Sprite & bar = AGG::GetICN(ICN::HSBTNS, 8); bar.Blit(dst_pt); StatusBar statusBar; statusBar.SetCenter(dst_pt.x + bar.w() / 2, dst_pt.y + 11); // button prev dst_pt.x = cur_pt.x + 1; dst_pt.y = cur_pt.y + 480 - 20; Button buttonPrevHero(dst_pt, ICN::HSBTNS, 4, 5); // button next dst_pt.x = cur_pt.x + 640 - 23; dst_pt.y = cur_pt.y + 480 - 20; Button buttonNextHero(dst_pt, ICN::HSBTNS, 6, 7); // button dismiss dst_pt.x = cur_pt.x + 5; dst_pt.y = cur_pt.y + 318; Button buttonDismiss(dst_pt, ICN::HSBTNS, 0, 1); // button exit dst_pt.x = cur_pt.x + 603; dst_pt.y = cur_pt.y + 318; Button buttonExit(dst_pt, ICN::HSBTNS, 2, 3); LocalEvent & le = LocalEvent::Get(); if(castle || readonly || Modes(NOTDISMISS)) { buttonDismiss.Press(); buttonDismiss.SetDisable(true); } if(readonly || 2 > world.GetKingdom(GetColor()).GetHeroes().size()) { buttonNextHero.Press(); buttonPrevHero.Press(); buttonNextHero.SetDisable(true); buttonPrevHero.SetDisable(true); } buttonPrevHero.Draw(); buttonNextHero.Draw(); buttonDismiss.Draw(); buttonExit.Draw(); cursor.Show(); display.Flip(); bool redrawMorale = false; bool redrawLuck = false; // dialog menu loop while(le.HandleEvents()) { if(redrawMorale) { cursor.Hide(); moraleIndicator.Redraw(); cursor.Show(); display.Flip(); redrawMorale = false; } if(redrawLuck) { cursor.Hide(); luckIndicator.Redraw(); cursor.Show(); display.Flip(); redrawLuck = false; } // exit if(le.MouseClickLeft(buttonExit) || Game::HotKeyPress(Game::EVENT_DEFAULT_EXIT)) return Dialog::CANCEL; // heroes troops if(le.MouseCursor(selectArmy.GetArea())) { if(SelectArmyBar::QueueEventProcessing(selectArmy)) { redrawMorale = true; redrawLuck = true; } } if(le.MouseCursor(selectArtifacts.GetArea())) { SelectArtifactsBar::QueueEventProcessing(selectArtifacts); { redrawMorale = true; redrawLuck = true; } } // button click le.MousePressLeft(buttonExit) ? buttonExit.PressDraw() : buttonExit.ReleaseDraw(); if(buttonDismiss.isEnable()) le.MousePressLeft(buttonDismiss) ? buttonDismiss.PressDraw() : buttonDismiss.ReleaseDraw(); if(buttonPrevHero.isEnable()) le.MousePressLeft(buttonPrevHero) ? buttonPrevHero.PressDraw() : buttonPrevHero.ReleaseDraw(); if(buttonNextHero.isEnable()) le.MousePressLeft(buttonNextHero) ? buttonNextHero.PressDraw() : buttonNextHero.ReleaseDraw(); // prev hero if(buttonPrevHero.isEnable() && le.MouseClickLeft(buttonPrevHero)){ return Dialog::PREV; } // next hero if(buttonNextHero.isEnable() && le.MouseClickLeft(buttonNextHero)){ return Dialog::NEXT; } // dismiss if(buttonDismiss.isEnable() && le.MouseClickLeft(buttonDismiss) && Dialog::YES == Dialog::Message(GetName(), _("Are you sure you want to dismiss this Hero?"), Font::BIG, Dialog::YES | Dialog::NO)) { return Dialog::DISMISS; } if(le.MouseCursor(moraleIndicator.GetArea())) MoraleIndicator::QueueEventProcessing(moraleIndicator); else if(le.MouseCursor(luckIndicator.GetArea())) LuckIndicator::QueueEventProcessing(luckIndicator); else if(le.MouseCursor(experienceInfo.GetArea())) experienceInfo.QueueEventProcessing(); else if(le.MouseCursor(spellPointsInfo.GetArea())) spellPointsInfo.QueueEventProcessing(); // left click info if(le.MouseClickLeft(rectAttackSkill)) Dialog::Message(_("Attack Skill"), attackDescription, Font::BIG, Dialog::OK); else if(le.MouseClickLeft(rectDefenseSkill)) Dialog::Message(_("Defense Skill"), defenseDescription, Font::BIG, Dialog::OK); else if(le.MouseClickLeft(rectSpellSkill)) Dialog::Message(_("Spell Power"), powerDescription, Font::BIG, Dialog::OK); else if(le.MouseClickLeft(rectKnowledgeSkill)) Dialog::Message(_("Knowledge"), knowledgeDescription, Font::BIG, Dialog::OK); else if(!readonly && le.MouseClickLeft(rectSpreadArmyFormat) && Army::FORMAT_SPREAD != army.GetCombatFormat()) { cursor.Hide(); cursorFormat.Move(army1_pt); cursor.Show(); display.Flip(); army.SetCombatFormat(Army::FORMAT_SPREAD); #ifdef WITH_NET FH2LocalClient::SendArmyCombatFormation(army); #endif } else if(!readonly && le.MouseClickLeft(rectGroupedArmyFormat) && Army::FORMAT_SPREAD == army.GetCombatFormat()) { cursor.Hide(); cursorFormat.Move(army2_pt); cursor.Show(); display.Flip(); army.SetCombatFormat(Army::FORMAT_GROUPED); #ifdef WITH_NET FH2LocalClient::SendArmyCombatFormation(army); #endif } if(le.MouseCursor(secskill_bar.GetArea())) secskill_bar.QueueEventProcessing(); // right info if(le.MousePressRight(rectAttackSkill)) Dialog::Message(_("Attack Skill"), attackDescription, Font::BIG); else if(le.MousePressRight(rectDefenseSkill)) Dialog::Message(_("Defense Skill"), defenseDescription, Font::BIG); else if(le.MousePressRight(rectSpellSkill)) Dialog::Message(_("Spell Power"), powerDescription, Font::BIG); else if(le.MousePressRight(rectKnowledgeSkill)) Dialog::Message(_("Knowledge"), knowledgeDescription, Font::BIG); else if(le.MousePressRight(rectSpreadArmyFormat)) Dialog::Message(_("Spread Formation"), descriptionSpreadArmyFormat, Font::BIG); else if(le.MousePressRight(rectGroupedArmyFormat)) Dialog::Message(_("Grouped Formation"), descriptionGroupedArmyFormat, Font::BIG); // status message if(le.MouseCursor(rectAttackSkill)) statusBar.ShowMessage(_("View Attack Skill Info")); else if(le.MouseCursor(rectDefenseSkill)) statusBar.ShowMessage(_("View Defense Skill Info")); else if(le.MouseCursor(rectSpellSkill)) statusBar.ShowMessage(_("View Spell Power Info")); else if(le.MouseCursor(rectKnowledgeSkill)) statusBar.ShowMessage(_("View Knowledge Info")); else if(le.MouseCursor(moraleIndicator.GetArea())) statusBar.ShowMessage(_("View Morale Info")); else if(le.MouseCursor(luckIndicator.GetArea())) statusBar.ShowMessage(_("View Luck Info")); else if(le.MouseCursor(experienceInfo.GetArea())) statusBar.ShowMessage(_("View Experience Info")); else if(le.MouseCursor(spellPointsInfo.GetArea())) statusBar.ShowMessage(_("View Spell Points Info")); else if(le.MouseCursor(rectSpreadArmyFormat)) statusBar.ShowMessage(_("Set army combat formation to 'Spread'")); else if(le.MouseCursor(rectGroupedArmyFormat)) statusBar.ShowMessage(_("Set army combat formation to 'Grouped'")); else if(le.MouseCursor(buttonExit)) statusBar.ShowMessage(_("Exit hero")); else if(le.MouseCursor(buttonDismiss)) { if(Modes(NOTDISMISS)) statusBar.ShowMessage("Dismiss disabled, see game info"); else statusBar.ShowMessage(_("Dismiss hero")); } else if(le.MouseCursor(buttonPrevHero)) statusBar.ShowMessage(_("Show prev heroes")); else if(le.MouseCursor(buttonNextHero)) statusBar.ShowMessage(_("Show next heroes")); else // status message over artifact if(le.MouseCursor(selectArtifacts.GetArea())) { const s8 index = selectArtifacts.GetIndexFromCoord(le.GetMouseCursor()); if(0 <= index && index < HEROESMAXARTIFACT && bag_artifacts[index] != Artifact::UNKNOWN) { message = _("View %{art} Info"); String::Replace(message, "%{art}", bag_artifacts[index].GetName()); statusBar.ShowMessage(message); } else statusBar.ShowMessage(_("Hero Screen")); } else // status message over skill if(le.MouseCursor(secskill_bar.GetArea())) { const u8 ii = secskill_bar.GetIndexFromCoord(le.GetMouseCursor()); if(ii < secondary_skills.size()) { const Skill::Secondary & skill = secondary_skills[ii]; if(skill.isValid()) { message = _("View %{skill} Info"); String::Replace(message, "%{skill}", skill.GetName()); statusBar.ShowMessage(message); } else statusBar.ShowMessage(_("Hero Screen")); } else statusBar.ShowMessage(_("Hero Screen")); } else // status message over troops if(le.MouseCursor(selectArmy.GetArea())) { const s8 index1 = selectArmy.GetIndexFromCoord(le.GetMouseCursor()); if(0 <= index1) { const Army::Troop & troop1 = army.At(index1); const std::string & monster1 = troop1.GetName(); if(selectArmy.isSelected()) { const u8 index2 = selectArmy.Selected(); const Army::Troop & troop2 = army.At(index2); const std::string & monster2 = troop2.GetName(); if(index1 == index2) { message = _("View %{monster}"); String::Replace(message, "%{monster}", monster1); } else if(troop1.isValid() && troop2.isValid()) { message = troop1() == troop2() ? _("Combine %{monster1} armies") : _("Exchange %{monster2} with %{monster1}"); String::Replace(message, "%{monster1}", monster1); String::Replace(message, "%{monster2}", monster2); } else { message = _("Move and right click Redistribute %{monster}"); String::Replace(message, "%{monster}", monster2); } } else if(troop1.isValid()) { message = _("Select %{monster}"); String::Replace(message, "%{monster}", monster1); } else message = _("Empty"); statusBar.ShowMessage(message); } else statusBar.ShowMessage(_("Hero Screen")); } else // clear all statusBar.ShowMessage(_("Hero Screen")); } return Dialog::ZERO; }
/* readonly: false, fade: false */ Dialog::answer_t Heroes::OpenDialog(bool readonly, bool fade) { if(Settings::Get().QVGA()) return PocketPC::HeroesOpenDialog(*this, readonly); Display & display = Display::Get(); Cursor & cursor = Cursor::Get(); cursor.Hide(); cursor.SetThemes(cursor.POINTER); // fade if(fade && Settings::Get().ExtGameUseFade()) display.Fade(); Dialog::FrameBorder background(Size(640, 480)); const Point & cur_pt = background.GetArea(); Point dst_pt(cur_pt); AGG::GetICN(ICN::HEROBKG, 0).Blit(dst_pt); AGG::GetICN(Settings::Get().ExtGameEvilInterface() ? ICN::HEROEXTE : ICN::HEROEXTG, 0).Blit(dst_pt); std::string message; // portrait dst_pt.x = cur_pt.x + 49; dst_pt.y = cur_pt.y + 31; const Rect portPos(dst_pt.x, dst_pt.y, 101, 93); PortraitRedraw(dst_pt.x, dst_pt.y, PORT_BIG, display); // name message = _("%{name} the %{race} ( Level %{level} )"); StringReplace(message, "%{name}", name); StringReplace(message, "%{race}", Race::String(race)); StringReplace(message, "%{level}", GetLevel()); Text text(message, Font::BIG); text.Blit(cur_pt.x + 320 - text.w() / 2, cur_pt.y + 1); PrimarySkillsBar primskill_bar(this, false); primskill_bar.SetColRows(4, 1); primskill_bar.SetHSpace(6); primskill_bar.SetPos(cur_pt.x + 156, cur_pt.y + 31); primskill_bar.Redraw(); // morale dst_pt.x = cur_pt.x + 514; dst_pt.y = cur_pt.y + 35; MoraleIndicator moraleIndicator(*this); moraleIndicator.SetPos(dst_pt); moraleIndicator.Redraw(); // luck dst_pt.x = cur_pt.x + 552; dst_pt.y = cur_pt.y + 35; LuckIndicator luckIndicator(*this); luckIndicator.SetPos(dst_pt); luckIndicator.Redraw(); // army format spread dst_pt.x = cur_pt.x + 515; dst_pt.y = cur_pt.y + 63; const Sprite & sprite1 = AGG::GetICN(ICN::HSICONS, 9); sprite1.Blit(dst_pt); const Rect rectSpreadArmyFormat(dst_pt, sprite1.w(), sprite1.h()); const std::string descriptionSpreadArmyFormat = _("'Spread' combat formation spreads your armies from the top to the bottom of the battlefield, with at least one empty space between each army."); const Point army1_pt(dst_pt.x - 1, dst_pt.y - 1); // army format grouped dst_pt.x = cur_pt.x + 552; dst_pt.y = cur_pt.y + 63; const Sprite & sprite2 = AGG::GetICN(ICN::HSICONS, 10); sprite2.Blit(dst_pt); const Rect rectGroupedArmyFormat(dst_pt, sprite2.w(), sprite2.h()); const std::string descriptionGroupedArmyFormat = _("'Grouped' combat formation bunches your army together in the center of your side of the battlefield."); const Point army2_pt(dst_pt.x - 1, dst_pt.y - 1); // cursor format SpriteMove cursorFormat(AGG::GetICN(ICN::HSICONS, 11)); cursorFormat.Move(army.isSpreadFormat() ? army1_pt : army2_pt); // experience ExperienceIndicator experienceInfo(*this); experienceInfo.SetPos(Point(cur_pt.x + 514, cur_pt.y + 85)); experienceInfo.Redraw(); // spell points SpellPointsIndicator spellPointsInfo(*this); spellPointsInfo.SetPos(Point(cur_pt.x + 549, cur_pt.y + 87)); spellPointsInfo.Redraw(); // crest dst_pt.x = cur_pt.x + 49; dst_pt.y = cur_pt.y + 130; AGG::GetICN(ICN::CREST, Color::NONE == GetColor() ? Color::GetIndex(Settings::Get().CurrentColor()) : Color::GetIndex(GetColor())).Blit(dst_pt); // monster dst_pt.x = cur_pt.x + 156; dst_pt.y = cur_pt.y + 130; ArmyBar selectArmy(&army, false, readonly); selectArmy.SetColRows(5, 1); selectArmy.SetPos(dst_pt.x, dst_pt.y); selectArmy.SetHSpace(6); selectArmy.Redraw(); // secskill SecondarySkillsBar secskill_bar(false); secskill_bar.SetColRows(8, 1); secskill_bar.SetHSpace(5); secskill_bar.SetContent(secondary_skills); secskill_bar.SetPos(cur_pt.x + 3, cur_pt.y + 233); secskill_bar.Redraw(); dst_pt.x = cur_pt.x + 51; dst_pt.y = cur_pt.y + 308; ArtifactsBar selectArtifacts(this, false, readonly); selectArtifacts.SetColRows(7, 2); selectArtifacts.SetHSpace(15); selectArtifacts.SetVSpace(15); selectArtifacts.SetContent(GetBagArtifacts()); selectArtifacts.SetPos(dst_pt.x, dst_pt.y); selectArtifacts.Redraw(); // bottom small bar dst_pt.x = cur_pt.x + 22; dst_pt.y = cur_pt.y + 460; const Sprite & bar = AGG::GetICN(ICN::HSBTNS, 8); bar.Blit(dst_pt); StatusBar statusBar; statusBar.SetCenter(dst_pt.x + bar.w() / 2, dst_pt.y + 11); // button prev dst_pt.x = cur_pt.x + 1; dst_pt.y = cur_pt.y + 480 - 20; Button buttonPrevHero(dst_pt.x, dst_pt.y, ICN::HSBTNS, 4, 5); // button next dst_pt.x = cur_pt.x + 640 - 23; dst_pt.y = cur_pt.y + 480 - 20; Button buttonNextHero(dst_pt.x, dst_pt.y, ICN::HSBTNS, 6, 7); // button dismiss dst_pt.x = cur_pt.x + 5; dst_pt.y = cur_pt.y + 318; Button buttonDismiss(dst_pt.x, dst_pt.y, ICN::HSBTNS, 0, 1); // button exit dst_pt.x = cur_pt.x + 603; dst_pt.y = cur_pt.y + 318; Button buttonExit(dst_pt.x, dst_pt.y, ICN::HSBTNS, 2, 3); LocalEvent & le = LocalEvent::Get(); if(inCastle() || readonly || Modes(NOTDISMISS)) { buttonDismiss.Press(); buttonDismiss.SetDisable(true); } if(readonly || 2 > GetKingdom().GetHeroes().size()) { buttonNextHero.Press(); buttonPrevHero.Press(); buttonNextHero.SetDisable(true); buttonPrevHero.SetDisable(true); } buttonPrevHero.Draw(); buttonNextHero.Draw(); buttonDismiss.Draw(); buttonExit.Draw(); cursor.Show(); display.Flip(); bool redrawMorale = false; bool redrawLuck = false; message.clear(); // dialog menu loop while(le.HandleEvents()) { if(redrawMorale) { cursor.Hide(); moraleIndicator.Redraw(); cursor.Show(); display.Flip(); redrawMorale = false; } if(redrawLuck) { cursor.Hide(); luckIndicator.Redraw(); cursor.Show(); display.Flip(); redrawLuck = false; } // exit if(le.MouseClickLeft(buttonExit) || Game::HotKeyPress(Game::EVENT_DEFAULT_EXIT)) return Dialog::CANCEL; // heroes troops if(le.MouseCursor(selectArmy.GetArea()) && selectArmy.QueueEventProcessing(&message)) { cursor.Hide(); if(selectArtifacts.isSelected()) selectArtifacts.ResetSelected(); selectArmy.Redraw(); redrawMorale = true; redrawLuck = true; } if(le.MouseCursor(selectArtifacts.GetArea()) && selectArtifacts.QueueEventProcessing(&message)) { cursor.Hide(); if(selectArmy.isSelected()) selectArmy.ResetSelected(); selectArtifacts.Redraw(); redrawMorale = true; redrawLuck = true; } // button click le.MousePressLeft(buttonExit) ? buttonExit.PressDraw() : buttonExit.ReleaseDraw(); if(buttonDismiss.isEnable()) le.MousePressLeft(buttonDismiss) ? buttonDismiss.PressDraw() : buttonDismiss.ReleaseDraw(); if(buttonPrevHero.isEnable()) le.MousePressLeft(buttonPrevHero) ? buttonPrevHero.PressDraw() : buttonPrevHero.ReleaseDraw(); if(buttonNextHero.isEnable()) le.MousePressLeft(buttonNextHero) ? buttonNextHero.PressDraw() : buttonNextHero.ReleaseDraw(); // prev hero if(buttonPrevHero.isEnable() && le.MouseClickLeft(buttonPrevHero)){ return Dialog::PREV; } // next hero if(buttonNextHero.isEnable() && le.MouseClickLeft(buttonNextHero)){ return Dialog::NEXT; } // dismiss if(buttonDismiss.isEnable() && le.MouseClickLeft(buttonDismiss) && Dialog::YES == Dialog::Message(GetName(), _("Are you sure you want to dismiss this Hero?"), Font::BIG, Dialog::YES | Dialog::NO)) { return Dialog::DISMISS; } if(le.MouseCursor(moraleIndicator.GetArea())) MoraleIndicator::QueueEventProcessing(moraleIndicator); else if(le.MouseCursor(luckIndicator.GetArea())) LuckIndicator::QueueEventProcessing(luckIndicator); else if(le.MouseCursor(experienceInfo.GetArea())) experienceInfo.QueueEventProcessing(); else if(le.MouseCursor(spellPointsInfo.GetArea())) spellPointsInfo.QueueEventProcessing(); // left click info if(!readonly && le.MouseClickLeft(rectSpreadArmyFormat) && !army.isSpreadFormat()) { cursor.Hide(); cursorFormat.Move(army1_pt); cursor.Show(); display.Flip(); army.SetSpreadFormat(true); } else if(!readonly && le.MouseClickLeft(rectGroupedArmyFormat) && army.isSpreadFormat()) { cursor.Hide(); cursorFormat.Move(army2_pt); cursor.Show(); display.Flip(); army.SetSpreadFormat(false); } else if(le.MouseCursor(secskill_bar.GetArea()) && secskill_bar.QueueEventProcessing(&message)) { cursor.Show(); display.Flip(); } else if(le.MouseCursor(primskill_bar.GetArea()) && primskill_bar.QueueEventProcessing(&message)) { cursor.Show(); display.Flip(); } // right info if(le.MousePressRight(portPos)) Dialog::QuickInfo(*this); else if(le.MousePressRight(rectSpreadArmyFormat)) Dialog::Message(_("Spread Formation"), descriptionSpreadArmyFormat, Font::BIG); else if(le.MousePressRight(rectGroupedArmyFormat)) Dialog::Message(_("Grouped Formation"), descriptionGroupedArmyFormat, Font::BIG); // status message if(le.MouseCursor(portPos)) message = _("View Stats"); else if(le.MouseCursor(moraleIndicator.GetArea())) message = _("View Morale Info"); else if(le.MouseCursor(luckIndicator.GetArea())) message = _("View Luck Info"); else if(le.MouseCursor(experienceInfo.GetArea())) message = _("View Experience Info"); else if(le.MouseCursor(spellPointsInfo.GetArea())) message = _("View Spell Points Info"); else if(le.MouseCursor(rectSpreadArmyFormat)) message = _("Set army combat formation to 'Spread'"); else if(le.MouseCursor(rectGroupedArmyFormat)) message = _("Set army combat formation to 'Grouped'"); else if(le.MouseCursor(buttonExit)) message = _("Exit hero"); else if(le.MouseCursor(buttonDismiss)) { if(Modes(NOTDISMISS)) message = "Dismiss disabled, see game info"; else message = _("Dismiss hero"); } else if(le.MouseCursor(buttonPrevHero)) message = _("Show prev heroes"); else if(le.MouseCursor(buttonNextHero)) message = _("Show next heroes"); if(message.empty()) statusBar.ShowMessage(_("Hero Screen")); else { statusBar.ShowMessage(message); message.clear(); } } return Dialog::ZERO; }
void Dialog::Marketplace(bool fromTradingPost) { Display & display = Display::Get(); const ICN::icn_t tradpost = Settings::Get().EvilInterface() ? ICN::TRADPOSE : ICN::TRADPOST; const std::string & header = _("Marketplace"); Cursor & cursor = Cursor::Get(); cursor.Hide(); cursor.SetThemes(cursor.POINTER); Dialog::Box box(260, true); const Rect & pos_rt = box.GetArea(); Point dst_pt(pos_rt.x, pos_rt.y); Rect dst_rt(pos_rt); Text text; // header text.Set(header, Font::BIG); dst_pt.x = pos_rt.x + (pos_rt.w - text.w()) / 2; dst_pt.y = pos_rt.y; text.Blit(dst_pt); TradeWindowGUI gui(pos_rt); Kingdom & kingdom = world.GetMyKingdom(); const Sprite & spritecursor = AGG::GetICN(tradpost, 14); const std::string & header_from = _("Your Resources"); Resource::funds_t fundsFrom = kingdom.GetFundsResource(); u8 resourceFrom = 0; const Point pt1(pos_rt.x, pos_rt.y + 190); std::vector<Rect> rectsFrom(7); rectsFrom[0] = Rect(pt1.x, pt1.y, 34, 34); // wood rectsFrom[1] = Rect(pt1.x + 37, pt1.y, 34, 34); // mercury rectsFrom[2] = Rect(pt1.x + 74, pt1.y, 34, 34); // ore rectsFrom[3] = Rect(pt1.x, pt1.y + 37, 34, 34); // sulfur rectsFrom[4] = Rect(pt1.x + 37, pt1.y + 37, 34, 34);// crystal rectsFrom[5] = Rect(pt1.x + 74, pt1.y + 37, 34, 34);// gems rectsFrom[6] = Rect(pt1.x + 37, pt1.y + 74, 34, 34);// gold SpriteCursor cursorFrom(spritecursor); text.Set(header_from, Font::SMALL); dst_pt.x = pt1.x + (108 - text.w()) / 2; dst_pt.y = pt1.y - 15; text.Blit(dst_pt); RedrawFromResource(pt1, fundsFrom); const std::string & header_to = _("Available Trades"); Resource::funds_t fundsTo; u8 resourceTo = 0; const Point pt2(138 + pos_rt.x, pos_rt.y + 190); std::vector<Rect> rectsTo(7); rectsTo[0] = Rect(pt2.x, pt2.y, 34, 34); // wood rectsTo[1] = Rect(pt2.x + 37, pt2.y, 34, 34); // mercury rectsTo[2] = Rect(pt2.x + 74, pt2.y, 34, 34); // ore rectsTo[3] = Rect(pt2.x, pt2.y + 37, 34, 34); // sulfur rectsTo[4] = Rect(pt2.x + 37, pt2.y + 37, 34, 34); // crystal rectsTo[5] = Rect(pt2.x + 74, pt2.y + 37, 34, 34); // gems rectsTo[6] = Rect(pt2.x + 37, pt2.y + 74, 34, 34); // gold SpriteCursor cursorTo(spritecursor); text.Set(header_to, Font::SMALL); dst_pt.x = pt2.x + (108 - text.w()) / 2; dst_pt.y = pt2.y - 15; text.Blit(dst_pt); RedrawToResource(pt2, false, fromTradingPost); u32 count_sell = 0; u32 count_buy = 0; u32 max_sell = 0; u32 max_buy = 0; Button & buttonTrade = gui.buttonTrade; Button & buttonLeft = gui.buttonLeft; Button & buttonRight = gui.buttonRight; Splitter & splitter = gui.splitter; // button exit const Sprite & sprite_exit = AGG::GetICN(tradpost, 17); dst_pt.x = pos_rt.x + (pos_rt.w - sprite_exit.w()) / 2; dst_pt.y = pos_rt.y + pos_rt.h - sprite_exit.h(); Button buttonExit(dst_pt, tradpost, 17, 18); buttonExit.Draw(); cursor.Show(); display.Flip(); LocalEvent & le = LocalEvent::Get(); // message loop while(le.HandleEvents()) { if(buttonTrade.isEnable()) le.MousePressLeft(buttonTrade) ? buttonTrade.PressDraw() : buttonTrade.ReleaseDraw(); if(buttonLeft.isEnable()) le.MousePressLeft(buttonLeft) ? buttonLeft.PressDraw() : buttonLeft.ReleaseDraw(); if(buttonRight.isEnable()) le.MousePressLeft(buttonRight) ? buttonRight.PressDraw() : buttonRight.ReleaseDraw(); le.MousePressLeft(buttonExit) ? buttonExit.PressDraw() : buttonExit.ReleaseDraw(); if(le.MouseClickLeft(buttonExit) || le.KeyPress(KEY_RETURN) || le.KeyPress(KEY_ESCAPE)) break; // click from for(u8 ii = 0; ii < rectsFrom.size(); ++ii) { const Rect & rect_from = rectsFrom[ii]; if(le.MouseClickLeft(rect_from)) { switch(ii) { case 0: resourceFrom = Resource::WOOD; max_sell = fundsFrom.wood; break; case 1: resourceFrom = Resource::MERCURY; max_sell = fundsFrom.mercury; break; case 2: resourceFrom = Resource::ORE; max_sell = fundsFrom.ore; break; case 3: resourceFrom = Resource::SULFUR; max_sell = fundsFrom.sulfur; break; case 4: resourceFrom = Resource::CRYSTAL; max_sell = fundsFrom.crystal; break; case 5: resourceFrom = Resource::GEMS; max_sell = fundsFrom.gems; break; case 6: resourceFrom = Resource::GOLD; max_sell = fundsFrom.gold; break; default: break; } if(GetTradeCosts(resourceFrom, resourceTo, fromTradingPost)) { max_buy = Resource::GOLD == resourceTo ? max_sell * GetTradeCosts(resourceFrom, resourceTo, fromTradingPost) : max_sell / GetTradeCosts(resourceFrom, resourceTo, fromTradingPost); } count_sell = 0; count_buy = 0; cursor.Hide(); cursorFrom.Move(rect_from.x - 2, rect_from.y - 2); cursorFrom.Show(); if(resourceTo) cursorTo.Hide(); RedrawToResource(pt2, true, fromTradingPost, resourceFrom); if(resourceTo) cursorTo.Show(); if(resourceTo) gui.ShowTradeArea(resourceFrom, resourceTo, max_buy, max_sell, count_buy, count_sell, fromTradingPost); cursor.Show(); display.Flip(); } } // click to for(u8 ii = 0; ii < rectsTo.size(); ++ii) { const Rect & rect_to = rectsTo[ii]; if(le.MouseClickLeft(rect_to)) { switch(ii) { case 0: resourceTo = Resource::WOOD; break; case 1: resourceTo = Resource::MERCURY; break; case 2: resourceTo = Resource::ORE; break; case 3: resourceTo = Resource::SULFUR; break; case 4: resourceTo = Resource::CRYSTAL; break; case 5: resourceTo = Resource::GEMS; break; case 6: resourceTo = Resource::GOLD; break; default: break; } if(GetTradeCosts(resourceFrom, resourceTo, fromTradingPost)) { max_buy = Resource::GOLD == resourceTo ? max_sell * GetTradeCosts(resourceFrom, resourceTo, fromTradingPost) : max_sell / GetTradeCosts(resourceFrom, resourceTo, fromTradingPost); } count_sell = 0; count_buy = 0; cursor.Hide(); cursorTo.Move(rect_to.x - 2, rect_to.y - 2); if(resourceFrom) { cursorTo.Hide(); RedrawToResource(pt2, true, fromTradingPost, resourceFrom); cursorTo.Show(); gui.ShowTradeArea(resourceFrom, resourceTo, max_buy, max_sell, count_buy, count_sell, fromTradingPost); } cursor.Show(); display.Flip(); } } // move splitter if(buttonLeft.isEnable() && buttonRight.isEnable() && max_buy && le.MousePressLeft(splitter.GetRect())) { u32 seek = (le.GetMouseCursor().x - splitter.GetRect().x) * 100 / splitter.GetStep(); if(seek < splitter.Min()) seek = splitter.Min(); else if(seek > splitter.Max()) seek = splitter.Max(); count_buy = seek * (Resource::GOLD == resourceTo ? GetTradeCosts(resourceFrom, resourceTo, fromTradingPost) : 1); count_sell = seek * (Resource::GOLD == resourceTo ? 1: GetTradeCosts(resourceFrom, resourceTo, fromTradingPost)); cursor.Hide(); splitter.Move(seek); gui.RedrawInfoBuySell(count_sell, count_buy); cursor.Show(); display.Flip(); } // trade if(buttonTrade.isEnable() && le.MouseClickLeft(buttonTrade) && count_sell && count_buy) { kingdom.OddFundsResource(Resource::funds_t(static_cast<Resource::resource_t>(resourceFrom), count_sell)); kingdom.AddFundsResource(Resource::funds_t(static_cast<Resource::resource_t>(resourceTo), count_buy)); #ifdef WITH_NET FH2LocalClient::SendMarketSellResource(kingdom, resourceFrom, count_sell, fromTradingPost); FH2LocalClient::SendMarketBuyResource(kingdom, resourceTo, count_buy, fromTradingPost); #endif resourceTo = resourceFrom = Resource::UNKNOWN; gui.ShowTradeArea(resourceFrom, resourceTo, 0, 0, 0, 0, fromTradingPost); fundsFrom = kingdom.GetFundsResource(); cursorTo.Hide(); cursorFrom.Hide(); RedrawFromResource(pt1, fundsFrom); RedrawToResource(pt2, false, fromTradingPost, resourceFrom); display.Flip(); } // decrease trade resource if(count_buy && ((buttonLeft.isEnable() && le.MouseClickLeft(gui.buttonLeft)) || le.MouseWheelDn(splitter.GetRect()))) { count_buy -= Resource::GOLD == resourceTo ? GetTradeCosts(resourceFrom, resourceTo, fromTradingPost) : 1; count_sell -= Resource::GOLD == resourceTo ? 1: GetTradeCosts(resourceFrom, resourceTo, fromTradingPost); cursor.Hide(); splitter.Backward(); gui.RedrawInfoBuySell(count_sell, count_buy); cursor.Show(); display.Flip(); } // increase trade resource if( count_buy < max_buy && ((buttonRight.isEnable() && le.MouseClickLeft(buttonRight)) || le.MouseWheelUp(splitter.GetRect()))) { count_buy += Resource::GOLD == resourceTo ? GetTradeCosts(resourceFrom, resourceTo, fromTradingPost) : 1; count_sell += Resource::GOLD == resourceTo ? 1: GetTradeCosts(resourceFrom, resourceTo, fromTradingPost); cursor.Hide(); splitter.Forward(); gui.RedrawInfoBuySell(count_sell, count_buy); cursor.Show(); display.Flip(); } } }
void Kingdom::OverviewDialog(void) { Display & display = Display::Get(); Cursor & cursor = Cursor::Get(); cursor.Hide(); cursor.SetThemes(cursor.POINTER); Dialog::FrameBorder background(Size(640, 480)); const Point & cur_pt = background.GetArea(); Point dst_pt(cur_pt); AGG::GetICN(ICN::OVERBACK, 0).Blit(dst_pt); RedrawIncomeInfo(cur_pt, *this); RedrawFundsInfo(cur_pt, *this); StatsHeroesList listHeroes(dst_pt, heroes); StatsCastlesList listCastles(dst_pt, castles); // buttons dst_pt.x = cur_pt.x + 540; dst_pt.y = cur_pt.y + 360; Button buttonHeroes(dst_pt.x, dst_pt.y, ICN::OVERVIEW, 0, 1); dst_pt.x = cur_pt.x + 540; dst_pt.y = cur_pt.y + 405; Button buttonCastle(dst_pt.x, dst_pt.y, ICN::OVERVIEW, 2, 3); dst_pt.x = cur_pt.x + 540; dst_pt.y = cur_pt.y + 453; Button buttonExit(dst_pt.x, dst_pt.y, ICN::OVERVIEW, 4, 5); const Rect rectIncome(cur_pt.x + 1, cur_pt.y + 360, 535, 60); Interface::ListBasic* listStats = NULL; // set state view: castles if(Modes(OVERVIEWCSTL)) { buttonCastle.Press(); buttonHeroes.Release(); listStats = &listCastles; } else // set state view: heroes { buttonHeroes.Press(); buttonCastle.Release(); listStats = &listHeroes; } listStats->Redraw(); buttonHeroes.Draw(); buttonCastle.Draw(); buttonExit.Draw(); cursor.Show(); display.Flip(); LocalEvent & le = LocalEvent::Get(); // dialog menu loop while(le.HandleEvents()) { le.MousePressLeft(buttonExit) ? buttonExit.PressDraw() : buttonExit.ReleaseDraw(); // switch view: heroes/castle if(buttonHeroes.isReleased() && le.MouseClickLeft(buttonHeroes)) { cursor.Hide(); buttonHeroes.Press(); buttonCastle.Release(); buttonHeroes.Draw(); buttonCastle.Draw(); listStats = &listHeroes; ResetModes(OVERVIEWCSTL); } else if(buttonCastle.isReleased() && le.MouseClickLeft(buttonCastle)) { cursor.Hide(); buttonCastle.Press(); buttonHeroes.Release(); buttonHeroes.Draw(); buttonCastle.Draw(); listStats = &listCastles; SetModes(OVERVIEWCSTL); } // exit event if(le.MouseClickLeft(buttonExit) || Game::HotKeyPressEvent(Game::EVENT_DEFAULT_EXIT)) break; listStats->QueueEventProcessing(); if(le.MouseClickLeft(rectIncome)) Dialog::ResourceInfo("", "income:", GetIncome(INCOME_ALL), Dialog::OK); else if(le.MousePressRight(rectIncome)) Dialog::ResourceInfo("", "income:", GetIncome(INCOME_ALL), 0); // redraw if(! cursor.isVisible()) { listStats->Redraw(); RedrawFundsInfo(cur_pt, *this); cursor.Show(); display.Flip(); } } }
void Castle::OpenMageGuild(void) { Display & display = Display::Get(); // cursor Cursor & cursor = Cursor::Get(); cursor.Hide(); Dialog::FrameBorder frameborder; frameborder.SetPosition((display.w() - 640 - BORDERWIDTH * 2) / 2, (display.h() - 480 - BORDERWIDTH * 2) / 2, 640, 480); frameborder.Redraw(); const Point cur_pt(frameborder.GetArea().x, frameborder.GetArea().y); Point dst_pt(cur_pt); AGG::GetICN(ICN::STONEBAK, 0).Blit(dst_pt); std::string message; Text text; // bar dst_pt.x = cur_pt.x; dst_pt.y = cur_pt.y + 461; AGG::GetICN(ICN::WELLXTRA, 2).Blit(dst_pt); // text bar text.Set(_("The above spells have been added to your book."), Font::BIG); dst_pt.x = cur_pt.x + 280 - text.w() / 2; dst_pt.y = cur_pt.y + 461; text.Blit(dst_pt); const u8 level = GetLevelMageGuild(); // sprite ICN::icn_t icn = ICN::UNKNOWN; switch(race) { case Race::KNGT: icn = ICN::MAGEGLDK; break; case Race::BARB: icn = ICN::MAGEGLDB; break; case Race::SORC: icn = ICN::MAGEGLDS; break; case Race::WRLK: icn = ICN::MAGEGLDW; break; case Race::WZRD: icn = ICN::MAGEGLDZ; break; case Race::NECR: icn = ICN::MAGEGLDN; break; default: break; } const Sprite & sprite = AGG::GetICN(icn, level - 1); dst_pt.x = cur_pt.x + 90 - sprite.w() / 2; dst_pt.y = cur_pt.y + 290 - sprite.h(); sprite.Blit(dst_pt); RowSpells spells5(Point(cur_pt.x + 250, cur_pt.y + 5), *this, 5); RowSpells spells4(Point(cur_pt.x + 250, cur_pt.y + 95), *this, 4); RowSpells spells3(Point(cur_pt.x + 250, cur_pt.y + 185), *this, 3); RowSpells spells2(Point(cur_pt.x + 250, cur_pt.y + 275), *this, 2); RowSpells spells1(Point(cur_pt.x + 250, cur_pt.y + 365), *this, 1); spells1.Redraw(); spells2.Redraw(); spells3.Redraw(); spells4.Redraw(); spells5.Redraw(); // button exit dst_pt.x = cur_pt.x + 578; dst_pt.y = cur_pt.y + 461; Button buttonExit(dst_pt, ICN::WELLXTRA, 0, 1); buttonExit.Draw(); cursor.Show(); display.Flip(); LocalEvent & le = LocalEvent::Get(); // message loop while(le.HandleEvents()) { le.MousePressLeft(buttonExit) ? buttonExit.PressDraw() : buttonExit.ReleaseDraw(); if(le.MouseClickLeft(buttonExit) || HotKeyCloseWindow) break; if(spells1.QueueEventProcessing() || spells2.QueueEventProcessing() || spells3.QueueEventProcessing() || spells4.QueueEventProcessing() || spells5.QueueEventProcessing()); } }