Esempio n. 1
0
Point3d CameraOpenCV::UnProject(const Point2d& p2d)
{
#ifdef HAS_OPENCV
cv::Point2d uv(p2d.x,p2d.y),px;
const cv::Mat src_pt(1, 1, CV_64FC2, &uv);
cv::Mat dst_pt(1, 1, CV_64FC2, &px);
cv::undistortPoints(src_pt, dst_pt, cam_k, cam_d);
return Point3d(px.x,px.y,1.);
#else
Point3d result((p2d.x-cx)*fx_inv,(p2d.y-cy)*fy_inv,1.);

double r2,r4,r6;
r2=result.x*result.x+result.y*result.y;
r4=r2*r2;
r6=r4*r2;
double& X=result.x;
double& Y=result.y;

double a,b0,b,c;
b0=1+k1*r2+k2*r4+k3*r6;
a=2.0*p2;
b=b0+2.0*p1*Y;
c=p2*r2-X;
if(a*a>0.0000001) result.x= (sqrt(b*b-4.0*a*c)-b)/(a*2.0);

a=2.0*p1;
b=b0+2.0*p2*X;
c=p1*r2-Y;
if(a*a>0.0000001) result.y= (sqrt(b*b-4.0*a*c)-b)/(a*2.0);

return result;
#endif
}
Game::menu_t PocketPC::NewGame(void)
{
    Game::SetFixVideoMode();

    Cursor & cursor = Cursor::Get();
    Display & display = Display::Get();
    Settings & conf = Settings::Get();
    LocalEvent & le = LocalEvent::Get();

    cursor.Hide();
    cursor.SetThemes(cursor.POINTER);

    const Sprite &sprite = AGG::GetICN(ICN::HEROES, 0);
    Rect src_rt((sprite.w() - display.w()) / 2, 0, display.w(), display.h());
    display.Blit(sprite, src_rt, 0, 0);

    const Sprite &board = AGG::GetICN(ICN::QWIKTOWN, 0);
    src_rt = Rect(13, 0, board.w() - 13, board.h() - 13);
    Point dst_pt((display.w() - src_rt.w) / 2, (display.h() - src_rt.h) / 2);
    display.Blit(board, src_rt, dst_pt.x , dst_pt.y);

    Text text;

    text.Set("Free Heroes II", Font::YELLOW_BIG);
    text.Blit(dst_pt.x + (src_rt.w - text.w()) / 2, dst_pt.y + 12);

    text.Set(conf.BuildVersion(), Font::YELLOW_SMALL);
    text.Blit(dst_pt.x + (src_rt.w - text.w()) / 2, dst_pt.y + 148);

    text.Set(_("Standard Game"), Font::BIG);
    const Rect rectStandardGame(dst_pt.x + (src_rt.w - text.w()) / 2 - 5, dst_pt.y + 40 + 5, text.w() + 10, text.h() + 10);
    text.Blit(rectStandardGame);

    text.Set(_("Campaign Game"));
    const Rect rectCampaignGame(dst_pt.x + (src_rt.w - text.w()) / 2 - 5, dst_pt.y + 65 + 5, text.w() + 10, text.h() + 10);
    text.Blit(rectCampaignGame);

    text.Set(_("Multi-Player Game"));
    const Rect rectMultiGame(dst_pt.x + (src_rt.w - text.w()) / 2 - 5, dst_pt.y + 90 + 5, text.w() + 10, text.h() + 10);
    text.Blit(rectMultiGame);

    text.Set(_("Cancel"));
    const Rect rectCancel(dst_pt.x + (src_rt.w - text.w()) / 2 - 5, dst_pt.y + 115 + 5, text.w() + 10, text.h() + 10);
    text.Blit(rectCancel);

    cursor.Show();
    display.Flip();

    // mainmenu loop
    while(le.HandleEvents())
    {
        if(le.KeyPress(KEY_s) || le.MouseClickLeft(rectStandardGame)) return Game::NEWSTANDARD;
        else if(le.KeyPress(KEY_c) || le.MouseClickLeft(rectCampaignGame)) return Game::MAINMENU;
        else if(le.KeyPress(KEY_m) || le.MouseClickLeft(rectMultiGame)) return Game::NEWMULTI;
        else if(le.MouseClickLeft(rectCancel) || le.KeyPress(KEY_ESCAPE)) return Game::MAINMENU;
    }

    return Game::QUITGAME;
}
Game::menu_t PocketPC::NewMulti(void)
{
    Game::SetFixVideoMode();

    Cursor & cursor = Cursor::Get();
    Display & display = Display::Get();
    Settings & conf = Settings::Get();
    LocalEvent & le = LocalEvent::Get();

    cursor.Hide();
    cursor.SetThemes(cursor.POINTER);

    const Sprite &sprite = AGG::GetICN(ICN::HEROES, 0);
    Rect src_rt((sprite.w() - display.w()) / 2, 0, display.w(), display.h());
    display.Blit(sprite, src_rt, 0, 0);

    const Sprite &board = AGG::GetICN(ICN::QWIKTOWN, 0);
    src_rt = Rect(13, 0, board.w() - 13, board.h() - 13);
    Point dst_pt((display.w() - src_rt.w) / 2, (display.h() - src_rt.h) / 2);
    display.Blit(board, src_rt, dst_pt.x , dst_pt.y);

    Text text;

    text.Set("Free Heroes II", Font::YELLOW_BIG);
    text.Blit(dst_pt.x + (src_rt.w - text.w()) / 2, dst_pt.y + 12);

    text.Set(conf.BuildVersion(), Font::YELLOW_SMALL);
    text.Blit(dst_pt.x + (src_rt.w - text.w()) / 2, dst_pt.y + 148);

    text.Set(_("Hot Seat"), Font::BIG);
    const Rect rectHotSeat(dst_pt.x + (src_rt.w - text.w()) / 2 - 5, dst_pt.y + 40 + 5, text.w() + 10, text.h() + 10);
    text.Blit(rectHotSeat);

    text.Set(_("Network"));
    const Rect rectNetwork(dst_pt.x + (src_rt.w - text.w()) / 2 - 5, dst_pt.y + 65 + 5, text.w() + 10, text.h() + 10);
    text.Blit(rectNetwork);

    text.Set(_("Cancel"));
    const Rect rectCancel(dst_pt.x + (src_rt.w - text.w()) / 2 - 5, dst_pt.y + 115 + 5, text.w() + 10, text.h() + 10);
    text.Blit(rectCancel);

    cursor.Show();
    display.Flip();

    // mainmenu loop
    while(le.HandleEvents())
    {
        if(le.KeyPress(KEY_h) || le.MouseClickLeft(rectHotSeat)) return Game::NEWHOTSEAT;
        else if(le.KeyPress(KEY_n) || le.MouseClickLeft(rectNetwork))
        {
            Dialog::Message(_("Error"), _("This release is compiled without network support."), Font::BIG, Dialog::OK);
            return Game::MAINMENU;
        }
        else if(le.MouseClickLeft(rectCancel) || le.KeyPress(KEY_ESCAPE)) return Game::MAINMENU;
    }

    return Game::QUITGAME;
}
Esempio n. 4
0
void CastleRedrawTownName(const Castle & castle, const Point & dst)
{
    const Sprite & ramka = AGG::GetICN(ICN::TOWNNAME, 0);
    Point dst_pt(dst.x + 320 - ramka.w() / 2, dst.y + 248);
    ramka.Blit(dst_pt);

    Text text(castle.GetName(), Font::SMALL);
    dst_pt.x = dst.x + 320 - text.w() / 2;
    dst_pt.y = dst.y + 248;
    text.Blit(dst_pt);
}
cv::Point2d PinholeCameraModel::rectifyPoint(const cv::Point2d& uv_raw) const
{
  assert( initialized() );

  if (cache_->distortion_state == NONE)
    return uv_raw;
  if (cache_->distortion_state == UNKNOWN)
    throw Exception("Cannot call rectifyPoint when distortion is unknown.");
  assert(cache_->distortion_state == CALIBRATED);

  /// @todo cv::undistortPoints requires the point data to be float, should allow double
  cv::Point2f raw32 = uv_raw, rect32;
  const cv::Mat src_pt(1, 1, CV_32FC2, &raw32.x);
  cv::Mat dst_pt(1, 1, CV_32FC2, &rect32.x);
  cv::undistortPoints(src_pt, dst_pt, K_, D_, R_, P_);
  return rect32;
}
Esempio n. 6
0
void CvxImgMatch::SIFTMatching(const cv::Mat & srcImg, const cv::Mat & dstImg,
                               const SIFTMatchingParameter & param,
                               vector<cv::Point2d> & srcPts, vector<cv::Point2d> & dstPts)
{
    const double ratio_threshold = 0.7;
    double feature_distance_threshold = 0.5;

    vl_feat_sift_parameter sift_param;
    sift_param.edge_thresh = 10;
    sift_param.dim = 128;
    sift_param.nlevels = 3;

    vector<std::shared_ptr<sift_keypoint> > src_keypoints;
    vector<std::shared_ptr<sift_keypoint> > dst_keypoints;
    EigenVLFeatSIFT::extractSIFTKeypoint(srcImg, sift_param, src_keypoints, false);
    EigenVLFeatSIFT::extractSIFTKeypoint(dstImg, sift_param, dst_keypoints, false);

    Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> src_descriptors;
    Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> dst_descriptors;


    EigenVLFeatSIFT::descriptorToMatrix(src_keypoints, src_descriptors);
    EigenVLFeatSIFT::descriptorToMatrix(dst_keypoints, dst_descriptors);

    EigenFlann32F flann32;
    flann32.setData(dst_descriptors);

    vector<vector<int> >  indices;       // index of src descriptors
    vector<vector<float> > dists;
    flann32.search(src_descriptors, indices, dists, 2);

    for (int i = 0; i<src_keypoints.size(); i++) {
        double dis1 = dists[i][0];
        double dis2 = dists[i][1];
        if (dis1 < feature_distance_threshold && dis1 < dis2 * ratio_threshold) {
            int dst_index = indices[i][0];
            cv::Point2d src_pt(src_keypoints[i]->location_x(), src_keypoints[i]->location_y());
            cv::Point2d dst_pt(dst_keypoints[dst_index]->location_x(), dst_keypoints[dst_index]->location_y());
            srcPts.push_back(src_pt);
            dstPts.push_back(dst_pt);
        }
    }
    assert(srcPts.size() == dstPts.size());
}
Esempio n. 7
0
void SecondarySkillBar::Redraw(void)
{
    Point dst_pt(pos);
    Text text;
    text.Set(Font::SMALL);

    for(u8 ii = 0; ii < HEROESMAXSKILL; ++ii)
    {
        const Skill::Secondary & skill = ii < skills->size() ? skills->at(ii) : Skill::Secondary();

        if(skill.isValid())
        {
            const Sprite & sprite_skill = AGG::GetICN((use_mini_sprite ? ICN::MINISS : ICN::SECSKILL), (use_mini_sprite ? skill.GetIndexSprite2() : skill.GetIndexSprite1()));
            sprite_skill.Blit(dst_pt);

            if(use_mini_sprite)
	    {
        	text.Set(GetString(skill.Level()));
        	text.Blit(dst_pt.x + (sprite_skill.w() - text.w()) - 3, dst_pt.y + sprite_skill.h() - 12);
	    }
	    else
	    {
        	text.Set(Skill::Secondary::String(skill.Skill()));
        	text.Blit(dst_pt.x + (sprite_skill.w() - text.w()) / 2, dst_pt.y + 3);

        	text.Set(Skill::Level::String(skill.Level()));
        	text.Blit(dst_pt.x + (sprite_skill.w() - text.w()) / 2, dst_pt.y + 50);
	    }

    	    dst_pt.x += (use_mini_sprite ? 32 : sprite_skill.w()) + interval;
        }
	else
	{
            const Sprite & sprite_skill = AGG::GetICN((use_mini_sprite ? ICN::HSICONS : ICN::SECSKILL), 0);

	    if(use_mini_sprite)
        	sprite_skill.Blit(Rect((sprite_skill.w() - 32) / 2, 20, 32, 32), dst_pt);
	    else
        	sprite_skill.Blit(dst_pt);

    	    dst_pt.x += (use_mini_sprite ? 32 : sprite_skill.w()) + interval;
	}
    }
}
Esempio n. 8
0
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();
}
Game::menu_t PocketPC::MainMenu(void)
{
    Cursor & cursor = Cursor::Get();
    Display & display = Display::Get();
    LocalEvent & le = LocalEvent::Get();

    cursor.Hide();
    cursor.SetThemes(cursor.POINTER);

    const Sprite &sprite = AGG::GetICN(ICN::HEROES, 0);
    Rect src_rt((sprite.w() - display.w()) / 2, 0, display.w(), display.h());
    sprite.Blit(src_rt, 0, 0);

    const Sprite &board = AGG::GetICN(ICN::QWIKTOWN, 0);
    src_rt = Rect(13, 0, board.w() - 13, board.h() - 13);
    Point dst_pt((display.w() - src_rt.w) / 2, (display.h() - src_rt.h) / 2);
    board.Blit(src_rt, dst_pt.x , dst_pt.y);

    Text text;
    
    text.Set("Free Heroes II", Font::YELLOW_BIG);
    text.Blit(dst_pt.x + (src_rt.w - text.w()) / 2, dst_pt.y + 12);

    text.Set(_("New Game"), Font::BIG);
    const Rect rectNewGame(dst_pt.x + (src_rt.w - text.w()) / 2 - 5, dst_pt.y + 35, text.w() + 10, text.h() + 10);
    text.Blit(rectNewGame);

    text.Set(_("Load Game"));
    const Rect rectLoadGame(dst_pt.x + (src_rt.w - text.w()) / 2 - 5, dst_pt.y + 55, text.w() + 10, text.h() + 10);
    text.Blit(rectLoadGame);

    text.Set(_("Settings"));
    const Rect rectSettings(dst_pt.x + (src_rt.w - text.w()) / 2 - 5, dst_pt.y + 75, text.w() + 10, text.h() + 10);
    text.Blit(rectSettings);

    text.Set(_("High Scores"));
    const Rect rectHighScores(dst_pt.x + (src_rt.w - text.w()) / 2 - 5, dst_pt.y + 95, text.w() + 10, text.h() + 10);
    text.Blit(rectHighScores);

    text.Set(_("Credits"));
    const Rect rectCredits(dst_pt.x + (src_rt.w - text.w()) / 2 - 5, dst_pt.y + 115, text.w() + 10, text.h() + 10);
    text.Blit(rectCredits);

    text.Set(_("Quit"));
    const Rect rectQuitGame(dst_pt.x + (src_rt.w - text.w()) / 2 - 5, dst_pt.y + 135, text.w() + 10, text.h() + 10);
    text.Blit(rectQuitGame);

    cursor.Show();
    display.Flip();

    // mainmenu loop
    while(le.HandleEvents())
    {
	if(Game::HotKeyPress(Game::EVENT_BUTTON_NEWGAME) ||
		le.MouseClickLeft(rectNewGame)) return Game::NEWSTANDARD; //NEWGAME;
	else
	if(Game::HotKeyPress(Game::EVENT_BUTTON_LOADGAME) ||
		le.MouseClickLeft(rectLoadGame)) return Game::LOADGAME;
	else
	if(Game::HotKeyPress(Game::EVENT_BUTTON_SETTINGS) ||
		le.MouseClickLeft(rectSettings)){ Dialog::ExtSettings(false); cursor.Show(); display.Flip(); }
	else
	if(Game::HotKeyPress(Game::EVENT_BUTTON_CREDITS) ||
		le.MouseClickLeft(rectCredits)) return Game::CREDITS;
	else
	if(Game::HotKeyPress(Game::EVENT_BUTTON_HIGHSCORES) ||
		le.MouseClickLeft(rectHighScores)) return Game::HIGHSCORES;
	else
	if(Game::HotKeyPress(Game::EVENT_DEFAULT_EXIT) ||
		le.MouseClickLeft(rectQuitGame)) return Game::QUITGAME;
    }

    return Game::QUITGAME;
}
Esempio n. 10
0
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();
}
Esempio n. 11
0
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());
    }
}
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();
	}
    }
}
void PocketPC::ThievesGuild(bool oracle)
{
    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);
    background.Blit(Rect(0, 0, window_w, window_h), dst_rt);

    const Point & cur_pt = dst_rt;
    Point dst_pt(cur_pt);

    const u8 count = oracle ? 0xFF : world.GetKingdom(Settings::Get().CurrentColor()).GetCountBuilding(BUILD_THIEVESGUILD);

    std::vector<ValueColors> v;
    v.reserve(KINGDOMMAX);
    const Colors colors(Game::GetActualKingdomColors());
    u16 textx = 115;
    u16 startx = 120;
    u16 maxw = 200;
    Text text;
    text.Set(Font::SMALL);

    // head 1
    u8 ii = 0;
    for(ii = 0; ii < colors.size(); ++ii)
    {
	switch(ii+1)
	{
	    case 1: text.Set(_("1st")); break;
	    case 2: text.Set(_("2nd")); break;
	    case 3: text.Set(_("3rd")); break;
	    case 4: text.Set(_("4th")); break;
	    case 5: text.Set(_("5th")); break;
	    case 6: text.Set(_("6th")); break;
	    default: break;
	}

	dst_pt.x = cur_pt.x + startx + maxw / (colors.size() * 2) + ii * maxw / colors.size() - text.w() / 2;
	dst_pt.y = cur_pt.y + 25;
	text.Blit(dst_pt);
    }

    // button exit
    const Rect rectExit(dst_rt.x + dst_rt.w - 26, dst_rt.y + 7, 25, 25);
    AGG::GetICN(ICN::TOWNWIND, 12).Blit(rectExit.x, rectExit.y);

    text.Set(_("Number of Towns:"));
    dst_pt.x = cur_pt.x + textx - text.w();
    dst_pt.y = cur_pt.y + 35;
    text.Blit(dst_pt);

    dst_pt.x = cur_pt.x + startx;
    GetTownsInfo(v, colors);
    DrawFlags(v, dst_pt, maxw, colors.size());

    text.Set(_("Number of Castles:"));
    dst_pt.x = cur_pt.x + textx - text.w();
    dst_pt.y = cur_pt.y + 47;
    text.Blit(dst_pt);

    dst_pt.x = cur_pt.x + startx;
    GetCastlesInfo(v, colors);
    DrawFlags(v, dst_pt, maxw, colors.size());

    text.Set(_("Number of Heroes:"));
    dst_pt.x = cur_pt.x + textx - text.w();
    dst_pt.y = cur_pt.y + 59;
    text.Blit(dst_pt);

    dst_pt.x = cur_pt.x + startx;
    GetHeroesInfo(v, colors);
    DrawFlags(v, dst_pt, maxw, colors.size());

    text.Set(_("Gold in Treasury:"));
    dst_pt.x = cur_pt.x + textx - text.w();
    dst_pt.y = cur_pt.y + 71;
    text.Blit(dst_pt);

    dst_pt.x = cur_pt.x + startx;
    GetGoldsInfo(v, colors);
    if(1 < count) DrawFlags(v, dst_pt, maxw, colors.size());

    text.Set(_("Wood & Ore:"));
    dst_pt.x = cur_pt.x + textx - text.w();
    dst_pt.y = cur_pt.y + 83;
    text.Blit(dst_pt);

    dst_pt.x = cur_pt.x + startx;
    GetWoodOreInfo(v, colors);
    if(1 < count) DrawFlags(v, dst_pt, maxw, colors.size());

    text.Set(_("Gems, Cr, Slf & Mer:"));
    dst_pt.x = cur_pt.x + textx - text.w();
    dst_pt.y = cur_pt.y + 95;
    text.Blit(dst_pt);

    dst_pt.x = cur_pt.x + startx;
    GetGemsCrSlfMerInfo(v, colors);
    if(1 < count) DrawFlags(v, dst_pt, maxw, colors.size());

    text.Set(_("Obelisks Found:"));
    dst_pt.x = cur_pt.x + textx - text.w();
    dst_pt.y = cur_pt.y + 107;
    text.Blit(dst_pt);

    dst_pt.x = cur_pt.x + startx;
    GetObelisksInfo(v, colors);
    if(2 < count) DrawFlags(v, dst_pt, maxw, colors.size());

    text.Set(_("Total Army Strength:"));
    dst_pt.x = cur_pt.x + textx - text.w();
    dst_pt.y = cur_pt.y + 119;
    text.Blit(dst_pt);

    dst_pt.x = cur_pt.x + startx;
    GetArmyInfo(v, colors);
    if(3 < count) DrawFlags(v, dst_pt, maxw, colors.size());

    text.Set(_("Income:"));
    dst_pt.x = cur_pt.x + textx - text.w();
    dst_pt.y = cur_pt.y + 131;
    text.Blit(dst_pt);

    dst_pt.x = cur_pt.x + startx;
    GetIncomesInfo(v, colors);
    if(4 < count) DrawFlags(v, dst_pt, maxw, colors.size());

    textx = 75;
    startx = 80;
    maxw = 240;

    // head 2
    ii = 0;
    for(Colors::const_iterator
	color = colors.begin(); color != colors.end(); ++color)
    {
	text.Set(Color::String(*color), Font::SMALL);
	dst_pt.x = cur_pt.x + startx + maxw / (colors.size() * 2) + ii * maxw / colors.size() - text.w() / 2;
	dst_pt.y = cur_pt.y + 145;
	text.Blit(dst_pt);
	++ii;
    }

    text.Set(_("Best Hero:"));
    dst_pt.x = cur_pt.x + textx - text.w();
    dst_pt.y = cur_pt.y + 160;
    text.Blit(dst_pt);

    dst_pt.x = cur_pt.x + startx;
    GetBestHeroArmyInfo(v, colors);
    DrawHeroIcons(v, dst_pt, maxw);

    text.Set(_("Best Hero Stats:"));
    dst_pt.x = cur_pt.x + textx - text.w();
    dst_pt.y = cur_pt.y + 200;
    text.Blit(dst_pt);

    dst_pt.x = cur_pt.x + startx;
    //GetBestHeroStatsInfo(v);
    //if(1 < count) DrawHeroIcons(v, dst_pt, maxw);
/*
    text.Set(_("Personality:"));
    dst_pt.x = cur_pt.x + textx - text.w();
    dst_pt.y = cur_pt.y + 388;
    text.Blit(dst_pt);

    dst_pt.x = cur_pt.x + startx;
    //GetPersonalityInfo(v);
    //if(2 < count) DrawHeroIcons(v, dst_pt, maxw);

    text.Set(_("Best Monster:"));
    dst_pt.x = cur_pt.x + textx - text.w();
    dst_pt.y = cur_pt.y + 429;
    text.Blit(dst_pt);

    dst_pt.x = cur_pt.x + startx;
    //GetBestMonsterInfo(v);
    //if(3 < count) DrawHeroIcons(v, dst_pt, maxw);

    //buttonExit.Draw();
*/
    cursor.Show();
    display.Flip();

    // message loop
    while(le.HandleEvents())
    {
        if(le.MouseClickLeft(rectExit) || HotKeyCloseWindow) break;
    }
}
Esempio n. 14
0
/* 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;
}
Esempio n. 15
0
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 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();            
        }
    }
}
Esempio n. 17
0
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();
	}
    }
}
Esempio n. 18
0
void BuildingInfo::Redraw(void)
{
    if(BUILD_CAPTAIN == building)
    {
	RedrawCaptain();
    }
    else
    {
	int index = GetIndexBuildingSprite(building);

	if(BUILD_DISABLE == bcond)
	{
	    AGG::GetICN(ICN::BLDGXTRA, 0).RenderGrayScale().Blit(area.x, area.y, Display::Get());
	}
	else
	{
	    AGG::GetICN(ICN::BLDGXTRA, 0).Blit(area.x, area.y);
	}

	// build image
        if(BUILD_DISABLE == bcond && BUILD_TAVERN == building)
	    // skip tavern necr
	    Display::Get().FillRect(Rect(area.x + 1, area.y + 1, 135, 57), ColorBlack);
	else
	    AGG::GetICN(ICN::Get4Building(castle.GetRace()), index).Blit(area.x + 1, area.y + 1);

	const Sprite & sprite_allow = AGG::GetICN(ICN::TOWNWIND, 11);
	const Sprite & sprite_deny  = AGG::GetICN(ICN::TOWNWIND, 12);
	const Sprite & sprite_money = AGG::GetICN(ICN::TOWNWIND, 13);

	Point dst_pt(area.x + 115, area.y + 40);

	// indicator
	if(bcond == ALREADY_BUILT)
	    sprite_allow.Blit(dst_pt);
	else
	if(bcond == BUILD_DISABLE)
	{
	    sprite_deny.RenderGrayScale().Blit(dst_pt, Display::Get());
	}
	else
	if(bcond != ALLOW_BUILD)
        {
	    if(LACK_RESOURCES == bcond)
		sprite_money.Blit(dst_pt);
	    else
		sprite_deny.Blit(dst_pt);
	}

	// status bar
	if(bcond != BUILD_DISABLE && bcond != ALREADY_BUILT)
	{
	    dst_pt.x = area.x;
	    dst_pt.y = area.y + 58;
	    AGG::GetICN(ICN::CASLXTRA, bcond == ALLOW_BUILD ? 1 : 2).Blit(dst_pt);
	}

	// name
	Text text(Castle::GetStringBuilding(building, castle.GetRace()), Font::SMALL);
	dst_pt.x = area.x + 68 - text.w() / 2;
        dst_pt.y = area.y + 59;
	text.Blit(dst_pt);
    }
}
Esempio n. 19
0
/* 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;
}