本文整理汇总了C++中WFont类的典型用法代码示例。如果您正苦于以下问题:C++ WFont类的具体用法?C++ WFont怎么用?C++ WFont使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WFont类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ARGB
void AIStats::Render()
{
GameObserver * g = player->getObserver();
float x0 = 10;
if (player == g->players[1])
x0 = 280;
JRenderer::GetInstance()->FillRoundRect(x0, 10, 200, 180, 5, ARGB(50,0,0,0));
WFont * f = g->getResourceManager()->GetWFont(Fonts::MAIN_FONT);
int i = 0;
char buffer[512];
list<AIStat *>::iterator it;
for (it = stats.begin(); it != stats.end(); ++it)
{
if (i > 10)
break;
AIStat * stat = *it;
if (stat->value > 0)
{
MTGCard * card = MTGCollection()->getCardById(stat->source);
if (card)
{
sprintf(buffer, "%s %i", card->data->getName().c_str(), stat->value);
f->DrawString(buffer, x0 + 5, 10 + 16 * (float) i);
i++;
}
}
}
}
开发者ID:Rolzad73,项目名称:wagic,代码行数:29,代码来源:AIStats.cpp
示例2: Render
void DamagerDamaged::Render(CombatStep mode)
{
TransientCardView::Render();
WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT);
mFont->SetBase(0);
switch (mode)
{
case BLOCKERS:
case TRIGGERS:
case ORDER:
mFont->SetColor(ARGB(92,255,255,255));
break;
case FIRST_STRIKE:
case END_FIRST_STRIKE:
case DAMAGE:
case END_DAMAGE:
mFont->SetColor(ARGB(255, 255, 64, 0));
break;
}
char buf[6];
sprintf(buf, "%i", sumDamages());
mFont->DrawString(buf, actX - 14 * actZ + 5, actY - 14 * actZ);
}
开发者ID:Esplin,项目名称:wagic,代码行数:26,代码来源:DamagerDamaged.cpp
示例3: _
void DeckEditorMenu::drawDeckStatistics()
{
ostringstream deckStatsString;
deckStatsString
<< _("------- Deck Summary -----") << endl
<< _("Cards: ") << stw->cardCount << endl
<< _("Creatures: ") << setw(2) << stw->countCreatures
<< _(" Enchantments: ") << stw->countEnchantments << endl
<< _("Instants: ") << setw(4) << stw->countInstants
<< _(" Sorceries: ") << setw(2) << stw->countSorceries << endl
<< _("Lands: ")
<< _("A: ") << setw(2) << left << stw->countLandsPerColor[ Constants::MTG_COLOR_ARTIFACT ] + stw->countBasicLandsPerColor[ Constants::MTG_COLOR_ARTIFACT ] << " "
<< _("G: ") << setw(2) << left << stw->countLandsPerColor[ Constants::MTG_COLOR_GREEN ] + stw->countLandsPerColor[ Constants::MTG_COLOR_GREEN ] << " "
<< _("R: ") << setw(2) << left << stw->countLandsPerColor[ Constants::MTG_COLOR_RED ] + stw->countBasicLandsPerColor[ Constants::MTG_COLOR_RED ] << " "
<< _("U: ") << setw(2) << left << stw->countLandsPerColor[ Constants::MTG_COLOR_BLUE ] + stw->countBasicLandsPerColor[ Constants::MTG_COLOR_BLUE ] << " "
<< _("B: ") << setw(2) << left << stw->countLandsPerColor[ Constants::MTG_COLOR_BLACK ] + stw->countBasicLandsPerColor[ Constants::MTG_COLOR_BLACK ] << " "
<< _("W: ") << setw(2) << left << stw->countLandsPerColor[ Constants::MTG_COLOR_WHITE ] + stw->countBasicLandsPerColor[ Constants::MTG_COLOR_WHITE ] << endl
<< _(" --- Card color count --- ") << endl
<< _("A: ") << setw(2) << left << selectedDeck->getCount(Constants::MTG_COLOR_ARTIFACT) << " "
<< _("G: ") << setw(2) << left << selectedDeck->getCount(Constants::MTG_COLOR_GREEN) << " "
<< _("U: ") << setw(2) << left << selectedDeck->getCount(Constants::MTG_COLOR_BLUE) << " "
<< _("R: ") << setw(2) << left << selectedDeck->getCount(Constants::MTG_COLOR_RED) << " "
<< _("B: ") << setw(2) << left << selectedDeck->getCount(Constants::MTG_COLOR_BLACK) << " "
<< _("W: ") << setw(2) << left << selectedDeck->getCount(Constants::MTG_COLOR_WHITE) << endl
<< _(" --- Average Cost --- ") << endl
<< _("Creature: ") << setprecision(2) << stw->avgCreatureCost << endl
<< _("Mana: ") << setprecision(2) << stw->avgManaCost << " "
<< _("Spell: ") << setprecision(2) << stw->avgSpellCost << endl;
WFont *mainFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT);
mainFont->DrawString(deckStatsString.str().c_str(), descX, descY + 25);
}
开发者ID:Rolzad73,项目名称:wagic,代码行数:34,代码来源:DeckEditorMenu.cpp
示例4: matchFont
FontSupport::FontMatch FontSupport::matchFont(const WFont& font) const
{
for (MatchCache::iterator i = cache_.begin(); i != cache_.end(); ++i) {
if (i->font.genericFamily() == font.genericFamily() &&
i->font.specificFamilies() == font.specificFamilies() &&
i->font.weight() == font.weight() &&
i->font.style() == font.style()) {
cache_.splice(cache_.begin(), cache_, i); // implement LRU
return cache_.front().match;
}
}
FontMatch match;
for (unsigned i = 0; i < fontCollections_.size(); ++i) {
FontMatch m = matchFont(font, fontCollections_[i].directory,
fontCollections_[i].recursive);
if (m.quality() > match.quality())
match = m;
}
// implement LRU
cache_.pop_back();
cache_.push_front(Matched());
cache_.front().font = font;
cache_.front().match = match;
return match;
}
开发者ID:NovaWova,项目名称:wt,代码行数:30,代码来源:FontSupportSimple.C
示例5: beginPurchase
void GameStateShop::beginPurchase(int controlId)
{
WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MENU_FONT);
mFont->SetScale(SCALE_NORMAL);
SAFE_DELETE(menu);
if (mInventory[controlId] <= 0)
{
menu = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), -145, this, Fonts::MENU_FONT, SCREEN_WIDTH - 300, SCREEN_HEIGHT / 2, _("Sold Out").c_str());
menu->Add(-1, "Ok");
}
else if (playerdata->credits - mPrices[controlId] < 0)
{
menu = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), -145, this, Fonts::MENU_FONT, SCREEN_WIDTH - 300, SCREEN_HEIGHT / 2, _("Not enough credits").c_str());
menu->Add(-1, "Ok");
if (options[Options::CHEATMODE].number)
{
menu->Add(-2, _("Steal it").c_str());
}
}
else
{
char buf[512];
if (controlId < BOOSTER_SLOTS)
sprintf(buf, _("Purchase Booster: %i credits").c_str(), mPrices[controlId]);
else
sprintf(buf, _("Purchase Card: %i credits").c_str(), mPrices[controlId]);
menu = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), -145, this, Fonts::MENU_FONT, SCREEN_WIDTH - 300, SCREEN_HEIGHT / 2, buf);
menu->Add(controlId, "Yes");
menu->Add(-1, "No");
}
}
开发者ID:cymbiotica,项目名称:wagic,代码行数:32,代码来源:GameStateShop.cpp
示例6: Render
void InteractiveButton::Render()
{
if (!isSelectionValid()) return;
JRenderer *renderer = JRenderer::GetInstance();
WFont *mainFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT);
const string detailedInfoString = _(getText());
float stringWidth = mainFont->GetStringWidth(detailedInfoString.c_str());
float pspIconsSize = 0.5;
float mainFontHeight = mainFont->GetHeight();
float boxStartX = getX() - 5;
mXOffset = 0;
mYOffset = 0;
#ifndef TOUCH_ENABLED
renderer->FillRoundRect(boxStartX, getY(), stringWidth - 3, mainFontHeight - 9, 5, ARGB(0, 0, 0, 0));
#else
renderer->FillRoundRect(boxStartX, getY(), stringWidth - 3, mainFontHeight - 5, 5, ARGB(255, 192, 172, 119));
renderer->DrawRoundRect(boxStartX, getY(), stringWidth - 3, mainFontHeight - 5, 5, ARGB(255, 255, 255, 255));
mYOffset += 2;
#endif
float buttonXOffset = getX() - mXOffset;
float buttonYOffset = getY() + mYOffset;
if (buttonImage != NULL)
{
renderer->RenderQuad(buttonImage.get(), buttonXOffset - buttonImage.get()->mWidth/2, buttonYOffset + mainFontHeight/2, 0, pspIconsSize, pspIconsSize);
}
mainFont->SetColor(ARGB(255, 0, 0, 0));
mainFont->DrawString(detailedInfoString, buttonXOffset, buttonYOffset);
}
开发者ID:Esplin,项目名称:wagic,代码行数:30,代码来源:InteractiveButton.cpp
示例7: RenderWithOffset
void SimpleButton::RenderWithOffset(float yOffset)
{
mYOffset = yOffset;
WFont * mFont = WResourceManager::Instance()->GetWFont(mFontId);
mFont->SetScale(mScale);
mFont->DrawString(mText.c_str(), mX, mY + yOffset, JGETEXT_CENTER);
}
开发者ID:Azurami,项目名称:wagic,代码行数:9,代码来源:SimpleButton.cpp
示例8: GetWidth
float SimpleButton::GetWidth()
{
WFont * mFont = WResourceManager::Instance()->GetWFont(mFontId);
float backup = mFont->GetScale();
mFont->SetScale(1.0);
float result = mFont->GetStringWidth(mText.c_str());
mFont->SetScale(backup);
return result;
}
开发者ID:Azurami,项目名称:wagic,代码行数:9,代码来源:SimpleButton.cpp
示例9: Render
void ExtraCost::Render()
{
if (!mCostRenderString.empty())
{
WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT);
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
mFont->SetColor(ARGB(255,255,255,255));
mFont->DrawString(mCostRenderString, 20, 20, JGETEXT_LEFT);
}
}
开发者ID:SkyRaiderX,项目名称:wagic,代码行数:10,代码来源:ExtraCost.cpp
示例10: Render
void OptionProfile::Render()
{
JRenderer * renderer = JRenderer::GetInstance();
WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::OPTION_FONT);
mFont->SetScale(1);
int spacing = 2 + (int) mFont->GetHeight();
float pX, pY;
pX = x;
pY = y;
char buf[512];
if (selections[value] == "Default")
sprintf(buf, "player/avatar.jpg");
else
sprintf(buf, "profiles/%s/avatar.jpg", selections[value].c_str());
string filename = buf;
JQuadPtr avatar = WResourceManager::Instance()->RetrieveTempQuad(filename, TEXTURE_SUB_EXACT);
if (avatar)
{
renderer->RenderQuad(avatar.get(), x, pY);
pX += 40;
}
mFont->SetColor(getColor(WGuiColor::TEXT_HEADER));
mFont->DrawString(selections[value].c_str(), pX, pY + 2, JGETEXT_LEFT);
mFont->SetScale(0.8f);
mFont->SetColor(getColor(WGuiColor::TEXT_BODY));
mFont->DrawString(preview.c_str(), pX, pY + spacing + 2, JGETEXT_LEFT);
mFont->SetScale(1.0f);
}
开发者ID:Esplin,项目名称:wagic,代码行数:32,代码来源:OptionItem.cpp
示例11: switch
void FontSupport::matchFont(const WFont& font,
const std::vector<std::string>& fontNames,
const std::string& path,
FontMatch& match) const
{
if (boost::ends_with(path, ".ttf")
|| boost::ends_with(path, ".ttc")) {
std::string name = Utils::lowerCase(FileUtils::leaf(path));
name = name.substr(0, name.length() - 4);
Utils::replace(name, ' ', std::string());
std::vector<const char*> weightVariants, styleVariants;
if (font.weight() == WFont::Bold) {
weightVariants.push_back("bold");
weightVariants.push_back("bf");
} else {
weightVariants.push_back("");
}
switch (font.style()) {
case WFont::NormalStyle:
styleVariants.push_back("regular");
styleVariants.push_back("");
break;
case WFont::Italic:
styleVariants.push_back("italic");
styleVariants.push_back("oblique");
break;
case WFont::Oblique:
styleVariants.push_back("oblique");
break;
}
for (unsigned i = 0; i < fontNames.size(); ++i) {
double q = 1.0 - 0.1 * i;
if (q <= match.quality())
return;
for (unsigned w = 0; w < weightVariants.size(); ++w)
for (unsigned s = 0; s < styleVariants.size(); ++s) {
std::string fn = fontNames[i] + weightVariants[w] + styleVariants[s];
if (fn == name) {
match = FontMatch(path, q);
return;
}
}
}
}
}
开发者ID:NovaWova,项目名称:wt,代码行数:51,代码来源:FontSupportSimple.C
示例12: LOG_ERROR
FontSupport::FontMatch FontSupport::matchFont(const WFont& font,
const std::string& directory,
bool recursive) const
{
if (!FileUtils::exists(directory)
|| !FileUtils::isDirectory(directory)) {
LOG_ERROR("cannot read directory '" << directory << "'");
return FontMatch();
}
std::vector<std::string> fontNames;
std::string families = font.specificFamilies().toUTF8();
boost::split(fontNames, families, boost::is_any_of(","));
for (unsigned i = 0; i < fontNames.size(); ++i) {
std::string s = Utils::lowerCase(fontNames[i]); // UTF-8 !
boost::trim_if(s, boost::is_any_of("\"'"));
s = Utils::replace(s, ' ', std::string());
fontNames[i] = s;
}
switch (font.genericFamily()) {
case WFont::Serif:
fontNames.push_back("times");
fontNames.push_back("timesnewroman");
break;
case WFont::SansSerif:
fontNames.push_back("helvetica");
fontNames.push_back("arialunicode");
fontNames.push_back("arial");
fontNames.push_back("verdana");
break;
case WFont::Cursive:
fontNames.push_back("zapfchancery");
break;
case WFont::Fantasy:
fontNames.push_back("western");
break;
case WFont::Monospace:
fontNames.push_back("courier");
fontNames.push_back("mscouriernew");
break;
default:
;
}
FontMatch match;
matchFont(font, fontNames, directory, recursive, match);
return match;
}
开发者ID:NovaWova,项目名称:wt,代码行数:51,代码来源:FontSupportSimple.C
示例13: Render
void NextGamePhase::Render()
{
WFont * mFont = observer->getResourceManager()->GetWFont(Fonts::MAIN_FONT);
mFont->SetBase(0);
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
char buffer[200];
int playerId = 1;
if (observer->currentActionPlayer == observer->players[1])
playerId = 2;
sprintf(buffer, "%s %i : -> %s", _("Player").c_str(), playerId, observer->getNextGamePhaseName());
mFont->DrawString(buffer, x + 30, y, JGETEXT_LEFT);
}
开发者ID:zwvc,项目名称:wagic-x,代码行数:14,代码来源:ActionStack.cpp
示例14: Overlay
void OptionKey::Overlay()
{
JRenderer * renderer = JRenderer::GetInstance();
WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::OPTION_FONT);
mFont->SetColor(ARGB(255, 0, 0, 0));
if (grabbed)
{
static const float x = 30, y = 45;
renderer->FillRoundRect(x, y, SCREEN_WIDTH - 2 * x, 50, 2, ARGB(200, 200, 200, 255));
string msg = _("Press a key to associate.");
mFont->DrawString(msg, (SCREEN_WIDTH - mFont->GetStringWidth(msg.c_str())) / 2, y + 20);
}
else if (btnMenu)
btnMenu->Render();
}
开发者ID:Esplin,项目名称:wagic,代码行数:15,代码来源:OptionItem.cpp
示例15: matchFont
WFontMetrics FontSupport::fontMetrics(const WFont& font)
{
PANGO_LOCK;
enabledFontFormats = enabledFontFormats_;
PangoFont *pangoFont = matchFont(font).pangoFont();
PangoFontMetrics *metrics = pango_font_get_metrics(pangoFont, nullptr);
double ascent
= pangoUnitsToDouble(pango_font_metrics_get_ascent(metrics));
double descent
= pangoUnitsToDouble(pango_font_metrics_get_descent(metrics));
double leading = (ascent + descent) - font.sizeLength(12).toPixels();
// ascent < leading is an odd thing. it happens with a font like
// Cursive.
if (ascent > leading)
ascent -= leading;
else
leading = 0;
WFontMetrics result(font, leading, ascent, descent);
pango_font_metrics_unref(metrics);
return result;
}
开发者ID:AlexanderKotliar,项目名称:wt,代码行数:29,代码来源:FontSupportPango.C
示例16: ARGB
void DeckEditorMenu::Render()
{
JRenderer *r = JRenderer::GetInstance();
r->FillRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, ARGB(200,0,0,0));//bg??
DeckMenu::Render();
if (deckTitle.size() > 0)
{
WFont *mainFont = WResourceManager::Instance()->GetWFont(Fonts::OPTION_FONT);
DWORD currentColor = mainFont->GetColor();
mainFont->SetColor(ARGB(255,255,255,255));
mainFont->DrawString(deckTitle.c_str(), (SCREEN_WIDTH_F / 2)-15, (statsHeight / 2)+4, JGETEXT_CENTER);
mainFont->SetColor(currentColor);
}
if (stw && selectedDeck) drawDeckStatistics();
}
开发者ID:Rolzad73,项目名称:wagic,代码行数:18,代码来源:DeckEditorMenu.cpp
示例17: while
/* This alters the card structure, but this is intentional for performance and
* space purpose: The only time we get the card text is to render it
* on the screen, in a formatted way.
* Formatting the string every frame is not efficient, especially since we always display it the same way
* Formatting all strings at startup is inefficient too.
* Instead, we format when requested, but only once, and cache the result.
* To avoid memory to blow up, in exchange of the cached result, we erase the original string
*/
const vector<string>& CardPrimitive::getFormattedText()
{
if (!text.size())
return formattedText;
std::string::size_type found = text.find_first_of("{}");
while (found != string::npos)
{
text[found] = '/';
found = text.find_first_of("{}", found + 1);
}
WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAGIC_FONT);
mFont->FormatText(text, formattedText);
text = "";
return formattedText;
};
开发者ID:Esplin,项目名称:wagic,代码行数:26,代码来源:CardPrimitive.cpp
示例18: transform
QFont transform(const WFont& font)
{
QFont f(QString::fromStdString(font.family()), font.pointSize(), font.weight(), font.italic());
f.setUnderline(font.underline());
f.setStrikeOut(font.strikeOut());
f.setKerning(font.kerning());
return f;
}
开发者ID:tecentwenping,项目名称:Controller_Atcsim,代码行数:8,代码来源:guitransform.cpp
示例19: fprintf
void GameApp::Render()
{
if (systemError.size())
{
fprintf(stderr, "%s", systemError.c_str());
WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT);
if (mFont)
mFont->DrawString(systemError.c_str(), 1, 1);
return;
}
JRenderer * renderer = JRenderer::GetInstance();
renderer->ClearScreen(ARGB(0,0,0,0));
if (mCurrentState)
mCurrentState->Render();
#ifdef DEBUG_CACHE
WResourceManager::Instance()->DebugRender();
#endif
#if defined(DEBUG) && !defined(IOS)
JGE* mEngine = JGE::GetInstance();
float fps = mEngine->GetFPS();
totalFPS += fps;
nbUpdates+=1;
WFont * mFont= WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT);
char buf[512];
sprintf(buf, "avg:%.02f - %.02f fps",totalFPS/nbUpdates, fps);
if (mFont)
{
mFont->SetColor(ARGB(255,255,255,255));
mFont->DrawString(buf, 10, SCREEN_HEIGHT-25);
}
#endif
}
开发者ID:cymbiotica,项目名称:wagic,代码行数:37,代码来源:GameApp.cpp
示例20: sprintf
void OptionTheme::Render()
{
JRenderer * renderer = JRenderer::GetInstance();
char buf[512];
if (!bChecked)
{
author = "";
bChecked = true;
if (selections[value] == "Default")
sprintf(buf, "%s", "graphics/themeinfo.txt");
else
sprintf(buf, "themes/%s/themeinfo.txt", selections[value].c_str());
string contents;
if (JFileSystem::GetInstance()->readIntoString(buf, contents))
{
std::stringstream stream(contents);
string temp;
std::getline(stream, temp);
for (unsigned int x = 0; x < 17 && x < temp.size(); x++)
{
if (isprint(temp[x])) //Clear stuff that breaks mFont->DrawString, cuts to 16 chars.
author += temp[x];
}
}
}
sprintf(buf, _("Theme: %s").c_str(), selections[value].c_str());
JQuadPtr q = getImage();
if (q)
{
float scale = 128 / q->mHeight;
renderer->RenderQuad(q.get(), x, y, 0, scale, scale);
}
WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::OPTION_FONT);
mFont->SetColor(getColor(WGuiColor::TEXT_HEADER));
mFont->DrawString(buf, x + 2, y + 2);
if (bChecked && author.size())
{
mFont->SetColor(getColor(WGuiColor::TEXT_BODY));
mFont->SetScale(0.8f);
float hi = mFont->GetHeight();
sprintf(buf, _("Artist: %s").c_str(), author.c_str());
mFont->DrawString(buf, x + 2, y + getHeight() - hi);
mFont->SetScale(1);
}
}
开发者ID:Esplin,项目名称:wagic,代码行数:47,代码来源:OptionItem.cpp
注:本文中的WFont类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论