本文整理汇总了C++中Text::Blit方法的典型用法代码示例。如果您正苦于以下问题:C++ Text::Blit方法的具体用法?C++ Text::Blit怎么用?C++ Text::Blit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Text
的用法示例。
在下文中一共展示了Text::Blit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RedrawCurrentInfo
void RedrawCurrentInfo(const Point & pos, u16 available, u32 result,
const payment_t & paymentMonster, const payment_t & paymentCosts)
{
Text text;
std::string str = _("Available: %{count}");
String::Replace(str, "%{count}", available);
text.Set(str, Font::SMALL);
text.Blit(pos.x + 70 - text.w() / 2, pos.y + 130);
text.Set(GetString(result), Font::BIG);
text.Blit(pos.x + 167 - text.w() / 2, pos.y + 160);
if(2 == paymentMonster.GetValidItems())
{
text.Set(GetString(paymentCosts.gold), Font::SMALL);
text.Blit(pos.x + 133 - text.w() / 2, pos.y + 228);
text.Set(GetString(paymentMonster.GetFirstValidItems(Resource::ALL & ~Resource::GOLD)), Font::SMALL);
text.Blit(pos.x + 195 - text.w() / 2, pos.y + 228);
}
else
{
text.Set(GetString(paymentCosts.gold), Font::SMALL);
text.Blit(pos.x + 160 - text.w() / 2, pos.y + 228);
}
}
示例2: NewMulti
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;
}
示例3: RedrawBackground
void ScenarioListBox::RedrawBackground(const Point & dst)
{
if(Settings::Get().QVGA())
{
AGG::GetICN(ICN::STONEBAK, 0).Blit(Rect(17, 37, 266, 156), dst.x + 15, dst.y + 35);
AGG::GetICN(ICN::REQSBKG, 0).Blit(Rect(325, 70, 16, 100), dst.x + 283, dst.y + 55);
AGG::GetICN(ICN::REQSBKG, 0).Blit(Rect(325, 167, 16, 50), dst.x + 283, dst.y + 125);
}
else
{
AGG::GetICN(ICN::REQSBKG, 0).Blit(dst);
if(content && cur != content->end())
{
Text text;
const Maps::FileInfo & info = *cur;
u8 index = 19 + Color::Count(info.kingdom_colors);
const Sprite & spriteCount = AGG::GetICN(ICN::REQUESTS, index);
spriteCount.Blit(dst.x + 65, dst.y + 265);
switch(info.size_w)
{
case Maps::SMALL: index = 26; break;
case Maps::MEDIUM: index = 27; break;
case Maps::LARGE: index = 28; break;
case Maps::XLARGE: index = 29; break;
default: index = 30; break;
}
const Sprite & spriteSize = AGG::GetICN(ICN::REQUESTS, index);
spriteSize.Blit(dst.x + 65 + spriteCount.w() + 2, dst.y + 265);
text.Set(info.name, Font::BIG);
text.Blit(dst.x + 190 - text.w() / 2, dst.y + 265);
index = 30 + info.conditions_wins;
const Sprite & spriteWins = AGG::GetICN(ICN::REQUESTS, index);
spriteWins.Blit(dst.x + 275, dst.y + 265);
index = 36 + info.conditions_loss;
const Sprite & spriteLoss = AGG::GetICN(ICN::REQUESTS, index);
spriteLoss.Blit(dst.x + 275 + spriteWins.w() + 2, dst.y + 265);
text.Set(_("Maps Difficulty:"), Font::BIG);
text.Blit(dst.x + 70, dst.y + 290);
text.Set(Difficulty::String(info.difficulty));
text.Blit(dst.x + 275 - text.w() / 2, dst.y + 290);
TextBox box(info.description, Font::BIG, 290);
box.Blit(dst.x + 45, dst.y + 320);
}
}
}
示例4: Redraw
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;
}
}
}
示例5: NewGame
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;
}
示例6: DrawBattleStats
void DrawBattleStats(const Point & dst, const Troop & b)
{
const u32 modes[] = {
Battle::SP_BLOODLUST, Battle::SP_BLESS, Battle::SP_HASTE, Battle::SP_SHIELD, Battle::SP_STONESKIN,
Battle::SP_DRAGONSLAYER, Battle::SP_STEELSKIN, Battle::SP_ANTIMAGIC, Battle::SP_CURSE, Battle::SP_SLOW,
Battle::SP_BERSERKER, Battle::SP_HYPNOTIZE, Battle::SP_BLIND, Battle::SP_PARALYZE, Battle::SP_STONE
};
// accumulate width
u32 ow = 0;
for(u32 ii = 0; ii < ARRAY_COUNT(modes); ++ii)
if(b.isModes(modes[ii]))
{
const Sprite & sprite = GetModesSprite(modes[ii]);
if(sprite.isValid()) ow += sprite.w() + 4;
}
ow -= 4;
ow = dst.x - ow / 2;
Text text;
// blit centered
for(u32 ii = 0; ii < ARRAY_COUNT(modes); ++ii)
if(b.isModes(modes[ii]))
{
const Sprite & sprite = GetModesSprite(modes[ii]);
if(sprite.isValid())
{
sprite.Blit(ow, dst.y);
const u32 duration = b.GetAffectedDuration(modes[ii]);
if(duration)
{
text.Set(GetString(duration), Font::SMALL);
text.Blit(ow + (sprite.w() - text.w()) / 2, dst.y + sprite.h() + 1);
}
ow += sprite.w() + 4;
}
}
}
示例7: RedrawScenarioStaticInfo
void RedrawScenarioStaticInfo(const Rect & rt)
{
Settings & conf = Settings::Get();
if(conf.QVGA())
{
const Sprite & background = AGG::GetICN(ICN::STONEBAK, 0);
background.Blit(Rect(0, 0, rt.w, rt.h), rt);
Text text;
text.Set(conf.CurrentFileInfo().name, Font::BIG);
text.Blit(rt.x + (rt.w - text.w()) / 2, rt.y + 5);
}
else
{
// image panel
const Sprite &panel = AGG::GetICN(ICN::NGHSBKG, 0);
panel.Blit(rt);
// text scenario
Text text(_("Scenario:"), Font::BIG);
text.Blit(rt.x + (rt.w - text.w()) / 2, rt.y + 20);
// maps name
text.Set(conf.MapsName());
text.Blit(rt.x + (rt.w - text.w()) / 2, rt.y + 46);
// text game difficulty
text.Set(_("Game Difficulty:"));
text.Blit(rt.x + (rt.w - text.w()) / 2, rt.y + 75);
// text opponents
text.Set(_("Opponents:"), Font::BIG);
text.Blit(rt.x + (rt.w - text.w()) / 2, rt.y + 181);
// text class
text.Set(_("Class:"), Font::BIG);
text.Blit(rt.x + (rt.w - text.w()) / 2, rt.y + 262);
}
}
示例8: RedrawItem
void ScenarioListBox::RedrawItem(const Maps::FileInfo & info, s16 dstx, s16 dsty, bool current)
{
Text text;
u8 index = 19 + Color::Count(info.kingdom_colors);
if(!Settings::Get().QVGA())
{
dstx = dstx - 10;
dsty = dsty + 2;
}
const Sprite & spriteCount = AGG::GetICN(ICN::REQUESTS, index);
spriteCount.Blit(dstx, dsty);
switch(info.size_w)
{
case Maps::SMALL: index = 26; break;
case Maps::MEDIUM: index = 27; break;
case Maps::LARGE: index = 28; break;
case Maps::XLARGE: index = 29; break;
default: index = 30; break;
}
const Sprite & spriteSize = AGG::GetICN(ICN::REQUESTS, index);
spriteSize.Blit(dstx + spriteCount.w() + 2, dsty);
text.Set(info.name, (current ? Font::YELLOW_BIG : Font::BIG));
text.Blit(dstx + 54, dsty + 2);
index = 30 + info.conditions_wins;
const Sprite & spriteWins = AGG::GetICN(ICN::REQUESTS, index);
spriteWins.Blit(dstx + 224, dsty);
index = 36 + info.conditions_loss;
const Sprite & spriteLoss = AGG::GetICN(ICN::REQUESTS, index);
spriteLoss.Blit(dstx + 224 + spriteWins.w() + 2, dsty);
}
示例9: Marketplace
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();
//.........这里部分代码省略.........
示例10: MakeGiftResource
void Dialog::MakeGiftResource(void)
{
Cursor & cursor = Cursor::Get();
Display & display = Display::Get();
LocalEvent & le = LocalEvent::Get();
const Settings & conf = Settings::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 & box = frameborder.GetArea();
const Sprite & background = AGG::GetICN(ICN::STONEBAK, 0);
background.Blit(Rect(0, 0, window_w, window_h), box);
Kingdom & myKingdom = world.GetKingdom(conf.CurrentColor());
Funds funds1(myKingdom.GetFunds());
Funds funds2;
Text text;
text.Set("Select Recipients");
text.Blit(box.x + (box.w - text.w()) / 2, box.y + 5);
SelectRecipientsColors selector(Point(box.x + 65, box.y + 28));
selector.Redraw();
text.Set("Your Funds");
text.Blit(box.x + (box.w - text.w()) / 2, box.y + 55);
ResourceBar info1(funds1, box.x + 25, box.y + 80);
info1.Redraw();
text.Set("Planned Gift");
text.Blit(box.x + (box.w - text.w()) / 2, box.y + 125);
ResourceBar info2(funds2, box.x + 25, box.y + 150);
info2.Redraw();
ButtonGroups btnGroups(box, Dialog::OK|Dialog::CANCEL);
btnGroups.DisableButton1(true);
btnGroups.Draw();
cursor.Show();
display.Flip();
u8 count = Color::Count(selector.recipients);
// message loop
u16 result = Dialog::ZERO;
while(result == Dialog::ZERO && le.HandleEvents())
{
if(selector.QueueEventProcessing())
{
u8 new_count = Color::Count(selector.recipients);
cursor.Hide();
btnGroups.DisableButton1(0 == new_count || 0 == funds2.GetValidItems());
if(count != new_count)
{
funds1 = myKingdom.GetFunds();
funds2.Reset();
info1.Redraw();
info2.Redraw();
count = new_count;
}
btnGroups.Draw();
selector.Redraw();
cursor.Show();
display.Flip();
}
else
if(info2.QueueEventProcessing(funds1, count))
{
cursor.Hide();
btnGroups.DisableButton1(0 == Color::Count(selector.recipients) || 0 == funds2.GetValidItems());
info1.Redraw();
info2.Redraw();
btnGroups.Draw();
cursor.Show();
display.Flip();
}
result = btnGroups.QueueEventProcessing();
}
if(Dialog::OK == result)
{
EventDate event;
event.resource = funds2;
event.computer = true;
//.........这里部分代码省略.........
示例11: ThievesGuild
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;
//.........这里部分代码省略.........
示例12: ArmyInfo
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())
{
//.........这里部分代码省略.........
示例13: ArmyJoinWithCost
int Dialog::ArmyJoinWithCost(const Troop & troop, u32 join, u32 gold, Heroes & hero)
{
Display & display = Display::Get();
const Settings & conf = Settings::Get();
// cursor
Cursor & cursor = Cursor::Get();
int oldthemes = cursor.Themes();
cursor.Hide();
cursor.SetThemes(cursor.POINTER);
std::string message;
if(troop.GetCount() == 1)
message = _("The creature is swayed by your diplomatic tongue, and offers to join your army for the sum of %{gold} gold.\nDo you accept?");
else
{
message = _("The creatures are swayed by your diplomatic\ntongue, and make you an offer:\n \n");
if(join != troop.GetCount())
message += _("%{offer} of the %{total} %{monster} will join your army, and the rest will leave you alone, for the sum of %{gold} gold.\nDo you accept?");
else
message += _("All %{offer} of the %{monster} will join your army for the sum of %{gold} gold.\nDo you accept?");
}
StringReplace(message, "%{offer}", join);
StringReplace(message, "%{total}", troop.GetCount());
StringReplace(message, "%{monster}", StringLower(troop.GetPluralName(join)));
StringReplace(message, "%{gold}", gold);
TextBox textbox(message, Font::BIG, BOXAREA_WIDTH);
const int buttons = Dialog::YES | Dialog::NO;
const Sprite & sprite = AGG::GetICN(ICN::RESOURCE, 6);
int posy = 0;
Text text;
message = _("(Rate: %{percent})");
StringReplace(message, "%{percent}", troop.GetMonster().GetCost().gold * join * 100 / gold);
text.Set(message, Font::BIG);
FrameBox box(10 + textbox.h() + 10 + text.h() + 40 + sprite.h() + 10, buttons);
const Rect & pos = box.GetArea();
posy = pos.y + 10;
textbox.Blit(pos.x, posy);
posy += textbox.h() + 10;
text.Blit(pos.x + (pos.w - text.w()) / 2, posy);
posy += text.h() + 40;
sprite.Blit(pos.x + (pos.w - sprite.w()) / 2, posy);
TextSprite tsTotal(GetString(gold) + " " + "(" + "total: " + GetString(world.GetKingdom(hero.GetColor()).GetFunds().Get(Resource::GOLD)) + ")", Font::SMALL,
pos.x + (pos.w - text.w()) / 2, posy + sprite.h() + 5);
tsTotal.Show();
ButtonGroups btnGroups(pos, buttons);
Button btnMarket(pos.x + pos.w / 2 - 60 - 36, posy, (conf.ExtGameEvilInterface() ? ICN::ADVEBTNS : ICN::ADVBTNS), 4, 5);
Button btnHeroes(pos.x + pos.w / 2 + 60, posy, (conf.ExtGameEvilInterface() ? ICN::ADVEBTNS : ICN::ADVBTNS), 0, 1);
const Kingdom & kingdom = hero.GetKingdom();
if(! kingdom.AllowPayment(payment_t(Resource::GOLD, gold)))
btnGroups.DisableButton1(true);
TextSprite tsEnough;
if(kingdom.GetCountMarketplace())
{
if(kingdom.AllowPayment(payment_t(Resource::GOLD, gold)))
btnMarket.SetDisable(true);
else
{
std::string msg = _("Not enough gold (%{gold})");
StringReplace(msg, "%{gold}", gold - kingdom.GetFunds().Get(Resource::GOLD));
tsEnough.SetText(msg, Font::YELLOW_SMALL);
tsEnough.SetPos(btnMarket.x - 25, btnMarket.y - 17);
tsEnough.Show();
btnMarket.Draw();
}
}
if(hero.GetArmy().GetCount() < hero.GetArmy().Size() || hero.GetArmy().HasMonster(troop))
btnHeroes.SetDisable(true);
else
{
TextBox textbox2(_("Not room in\nthe garrison"), Font::SMALL, 100);
textbox2.Blit(btnHeroes.x - 35, btnHeroes.y - 30);
btnHeroes.Draw();
btnGroups.DisableButton1(true);
}
btnGroups.Draw();
cursor.Show();
display.Flip();
LocalEvent & le = LocalEvent::Get();
// message loop
//.........这里部分代码省略.........
示例14: DwellingInfo
void Dialog::DwellingInfo(const Monster & monster, u16 available)
{
Display & display = Display::Get();
// cursor
Cursor & cursor = Cursor::Get();
const Cursor::themes_t oldcursor = cursor.Themes();
cursor.Hide();
cursor.SetThemes(cursor.POINTER);
const payment_t paymentMonster = monster.GetCost();
const Sprite & box = AGG::GetICN(ICN::RECR2BKG, 0);
const Rect pos((display.w() - box.w()) / 2, (display.h() - box.h()) / 2, box.w(), box.h());
Background back(pos);
back.Save();
box.Blit(pos.x, pos.y);
LocalEvent & le = LocalEvent::Get();
Point dst_pt;
Text text;
std::string str;
// text recruit monster
str = _("Recruit %{name}");
String::Replace(str, "%{name}", monster.GetMultiName());
text.Set(str, Font::BIG);
text.Blit(pos.x + (pos.w - text.w()) / 2, pos.y + 25);
// sprite monster
const Sprite & smon = AGG::GetICN(monster.ICNMonh(), 0);
dst_pt.x = pos.x + 70 - smon.w() / 2;
dst_pt.y = pos.y + 120 - smon.h();
smon.Blit(dst_pt);
bool extres = 2 == paymentMonster.GetValidItems();
// info resource
// gold
const Sprite & sgold = AGG::GetICN(ICN::RESOURCE, 6);
dst_pt.x = pos.x + (extres ? 150 : 175);
dst_pt.y = pos.y + 75;
sgold.Blit(dst_pt);
text.Set(GetString(paymentMonster.gold), Font::SMALL);
dst_pt.x = pos.x + (extres ? 183 : 205) - text.w() / 2;
dst_pt.y = pos.y + 103;
text.Blit(dst_pt);
// crystal
if(paymentMonster.crystal)
{
const Sprite & sres = AGG::GetICN(ICN::RESOURCE, 4);
RedrawResourceInfo(sres, pos, paymentMonster.crystal,
225, 75, 240, 103);
}
else
// mercury
if(paymentMonster.mercury)
{
const Sprite & sres = AGG::GetICN(ICN::RESOURCE, 1);
RedrawResourceInfo(sres, pos, paymentMonster.mercury,
225, 72, 240, 103);
}
else
// wood
if(paymentMonster.wood)
{
const Sprite & sres = AGG::GetICN(ICN::RESOURCE, 0);
RedrawResourceInfo(sres, pos, paymentMonster.wood,
225, 72, 240, 103);
}
else
// ore
if(paymentMonster.ore)
{
const Sprite & sres = AGG::GetICN(ICN::RESOURCE, 2);
RedrawResourceInfo(sres, pos, paymentMonster.ore,
225, 72, 240, 103);
}
else
// sulfur
if(paymentMonster.sulfur)
{
const Sprite & sres = AGG::GetICN(ICN::RESOURCE, 3);
RedrawResourceInfo(sres, pos, paymentMonster.sulfur,
225, 75, 240, 103);
}
else
// gems
if(paymentMonster.gems)
{
const Sprite & sres = AGG::GetICN(ICN::RESOURCE, 5);
RedrawResourceInfo(sres, pos, paymentMonster.gems,
225, 75, 240, 103);
}
// text available
str = _("Available: %{count}");
//.........这里部分代码省略.........
示例15: DrawMonsterStats
void DrawMonsterStats(const Point & dst, const Troop & troop)
{
Point dst_pt;
Text text;
bool pda = Settings::Get().QVGA();
// attack
text.Set(std::string(_("Attack")) + ":");
dst_pt.x = dst.x - text.w();
dst_pt.y = dst.y;
text.Blit(dst_pt);
const int ox = 10;
text.Set(troop.GetAttackString());
dst_pt.x = dst.x + ox;
text.Blit(dst_pt);
// defense
text.Set(std::string(_("Defense")) + ":");
dst_pt.x = dst.x - text.w();
dst_pt.y += (pda ? 14 : 18);
text.Blit(dst_pt);
text.Set(troop.GetDefenseString());
dst_pt.x = dst.x + ox;
text.Blit(dst_pt);
// shot
if(troop.isArchers())
{
std::string message = troop.isBattle() ? _("Shots Left") : _("Shots");
message.append(":");
text.Set(message);
dst_pt.x = dst.x - text.w();
dst_pt.y += (pda ? 14 : 18);
text.Blit(dst_pt);
text.Set(troop.GetShotString());
dst_pt.x = dst.x + ox;
text.Blit(dst_pt);
}
// damage
text.Set(std::string(_("Damage")) + ":");
dst_pt.x = dst.x - text.w();
dst_pt.y += (pda ? 14 : 18);
text.Blit(dst_pt);
if(troop().GetDamageMin() != troop().GetDamageMax())
text.Set(GetString(troop().GetDamageMin()) + " - " + GetString(troop().GetDamageMax()));
else
text.Set(GetString(troop().GetDamageMin()));
dst_pt.x = dst.x + ox;
text.Blit(dst_pt);
// hp
text.Set(std::string(_("Hit Points")) + ":");
dst_pt.x = dst.x - text.w();
dst_pt.y += (pda ? 14 : 18);
text.Blit(dst_pt);
text.Set(GetString(troop().GetHitPoints()));
dst_pt.x = dst.x + ox;
text.Blit(dst_pt);
if(troop.isBattle())
{
text.Set(std::string(_("Hit Points Left")) + ":");
dst_pt.x = dst.x - text.w();
dst_pt.y += (pda ? 14 : 18);
text.Blit(dst_pt);
text.Set(GetString(troop.GetHitPointsLeft()));
dst_pt.x = dst.x + ox;
text.Blit(dst_pt);
}
// speed
text.Set(std::string(_("Speed")) + ":");
dst_pt.x = dst.x - text.w();
dst_pt.y += (pda ? 14 : 18);
text.Blit(dst_pt);
text.Set(troop.GetSpeedString());
dst_pt.x = dst.x + ox;
text.Blit(dst_pt);
// morale
text.Set(std::string(_("Morale")) + ":");
dst_pt.x = dst.x - text.w();
dst_pt.y += (pda ? 14 : 18);
text.Blit(dst_pt);
text.Set(Morale::String(troop.GetMorale()));
dst_pt.x = dst.x + ox;
text.Blit(dst_pt);
// luck
text.Set(std::string(_("Luck")) + ":");
//.........这里部分代码省略.........