本文整理汇总了C++中Paragraph::setText方法的典型用法代码示例。如果您正苦于以下问题:C++ Paragraph::setText方法的具体用法?C++ Paragraph::setText怎么用?C++ Paragraph::setText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Paragraph
的用法示例。
在下文中一共展示了Paragraph::setText方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: askRocket
void Dialog::askRocket(){
if( !desktop ) {
std::cerr << "No desktop found.\n";
return;
}
try {
myDialogComponent = loadGUIFile( "gui/launch_rocket_yn.xml" );
assert( myDialogComponent != 0);
registerDialog();
blockingDialogIsOpen = true;
iAmBlocking = true;
} catch(std::exception& e) {
std::cerr << "Couldn't display message 'launch_rocket_yn': "
<< e.what() << "\n";
return;
}
Paragraph* p = getParagraph( *myDialogComponent, "DialogTitle" );
std::stringstream title;
title << _("Launchsite") << " ( " << pointX <<" , " << pointY << " )";
p->setText( title.str() );
// connect signals
Button* yesButton = getButton( *myDialogComponent, "Yes" );
yesButton->clicked.connect( makeCallback(*this, &Dialog::okayLaunchRocketButtonClicked ) );
Button* noButton = getButton( *myDialogComponent, "No" );
noButton->clicked.connect( makeCallback( *this, &Dialog::closeDialogButtonClicked ) );
Button* gotoButton = getButton( *myDialogComponent, "goto" );
gotoButton->clicked.connect( makeCallback( *this, &Dialog::gotoButtonClicked ) );
}
示例2: updateDate
void updateDate()
{
std::ostringstream dateText;
int day = total_time % NUMOF_DAYS_IN_MONTH +1; // 1..NUMOF_DAYS_IN_MONTH
day = 1 + ( 29 * day / NUMOF_DAYS_IN_MONTH ); // 1..30
dateText << day << ". ";
dateText << current_month( total_time );
dateText << " "<< current_year( total_time );
Component* root = getGameView();
if( !root ) return;
while( root->getParent() )
root = root->getParent();
if( dateText.str() == lastDateText ){
return;
}
Component* dateParagraphComponent = 0;
dateParagraphComponent = root->findComponent( "dateParagraph" );
if( dateParagraphComponent == 0 )
{ return;}
Paragraph* dateParagraph = getParagraph( *root, "dateParagraph");
if( !dateParagraph )
{ return;}
dateParagraph->setText( dateText.str() );
lastDateText = dateText.str();
}
示例3: updateMessageText
/*
* Update Message in Message Window
*/
void updateMessageText( const std::string text )
{
//Dialog Test
Component* root = getGameView();
if(!root) {
//happens while in menu.
std::cerr << "Root not found.\n";
return;
}
while( root->getParent() )
root = root->getParent();
Desktop* desktop = dynamic_cast<Desktop*> (root);
if(!desktop) {
std::cerr << "Root not a desktop!?!\n";
return;
}
try {
//test if message Windows is open
Component* messageTextComponent = 0;
messageTextComponent = root->findComponent( "messageText" );
if(messageTextComponent == 0) {
messageTextComponent = loadGUIFile("gui/messagearea.xml");
assert(messageTextComponent != 0);
desktop->addChildComponent(messageTextComponent);
}
Paragraph* messageText = getParagraph(*messageTextComponent, "messageText");
messageText->setText( text );
} catch(std::exception& e) {
std::cerr << "Couldn't display message '" << text << "': "
<< e.what() << "\n";
return;
}
}
示例4: editMarket
void Dialog::editMarket(){
if( !desktop ) {
std::cerr << "No desktop found.\n";
return;
}
try {
myDialogComponent = loadGUIFile( "gui/tradedialog.xml" );
assert( myDialogComponent != 0);
registerDialog();
blockingDialogIsOpen = true;
iAmBlocking = true;
} catch(std::exception& e) {
std::cerr << "Couldn't display dialog 'tradedialog.xml': "
<< e.what() << "\n";
return;
}
// set Dialog to Market-Data
Paragraph* p = getParagraph( *myDialogComponent, "DialogTitle" );
std::stringstream title;
title << _("Market") << " ( " << pointX <<" , " << pointY << " )";
p->setText( title.str() );
Market * market = static_cast <Market *> (world(pointX, pointY)->reportingConstruction);
CheckButton* cb;
cb = getCheckButton( *myDialogComponent, "BuyJobs" );
if( market->commodityRuleCount[Construction::STUFF_JOBS].take ) cb->check(); else cb->uncheck();
cb = getCheckButton( *myDialogComponent, "SellJobs" );
if( market->commodityRuleCount[Construction::STUFF_JOBS].give ) cb->check(); else cb->uncheck();
cb = getCheckButton( *myDialogComponent, "BuyFood" );
if( market->commodityRuleCount[Construction::STUFF_FOOD].take ) cb->check(); else cb->uncheck();
cb = getCheckButton( *myDialogComponent, "SellFood" );
if( market->commodityRuleCount[Construction::STUFF_FOOD].give ) cb->check(); else cb->uncheck();
cb = getCheckButton( *myDialogComponent, "BuyCoal" );
if( market->commodityRuleCount[Construction::STUFF_COAL].take ) cb->check(); else cb->uncheck();
cb = getCheckButton( *myDialogComponent, "SellCoal" );
if( market->commodityRuleCount[Construction::STUFF_COAL].give ) cb->check(); else cb->uncheck();
cb = getCheckButton( *myDialogComponent, "BuyOre" );
if( market->commodityRuleCount[Construction::STUFF_ORE].take ) cb->check(); else cb->uncheck();
cb = getCheckButton( *myDialogComponent, "SellOre" );
if( market->commodityRuleCount[Construction::STUFF_ORE].give ) cb->check(); else cb->uncheck();
cb = getCheckButton( *myDialogComponent, "BuyGoods" );
if( market->commodityRuleCount[Construction::STUFF_GOODS].take ) cb->check(); else cb->uncheck();
cb = getCheckButton( *myDialogComponent, "SellGoods" );
if( market->commodityRuleCount[Construction::STUFF_GOODS].give ) cb->check(); else cb->uncheck();
cb = getCheckButton( *myDialogComponent, "BuySteel" );
if( market->commodityRuleCount[Construction::STUFF_STEEL].take ) cb->check(); else cb->uncheck();
cb = getCheckButton( *myDialogComponent, "SellSteel" );
if( market->commodityRuleCount[Construction::STUFF_STEEL].give) cb->check(); else cb->uncheck();
cb = getCheckButton( *myDialogComponent, "BuyWaste" );
if( market->commodityRuleCount[Construction::STUFF_WASTE].take ) cb->check(); else cb->uncheck();
cb = getCheckButton( *myDialogComponent, "SellWaste" );
if( market->commodityRuleCount[Construction::STUFF_WASTE].give) cb->check(); else cb->uncheck();
// connect signals
Button* applyButton = getButton( *myDialogComponent, "Apply" );
applyButton->clicked.connect( makeCallback(*this, &Dialog::applyMarketButtonClicked ) );
Button* gotoButton = getButton( *myDialogComponent, "goto" );
gotoButton->clicked.connect( makeCallback( *this, &Dialog::gotoButtonClicked ) );
}
示例5: setParagraph
void Dialog::setParagraph( const std::string paragraphName, const std::string text ){
Paragraph* p;
try{
p = getParagraph( *myDialogComponent, paragraphName );
p->setText( text );
} catch(std::exception& e) {
std::cerr << "Couldn't set " << paragraphName << " to '" << text << "': "
<< e.what() << "\n";
}
}
示例6: editMarket
void Dialog::editMarket(){
if( !desktop ) {
std::cerr << "No desktop found.\n";
return;
}
try {
myDialogComponent = loadGUIFile( "gui/tradedialog.xml" );
assert( myDialogComponent != 0);
registerDialog();
blockingDialogIsOpen = true;
iAmBlocking = true;
} catch(std::exception& e) {
std::cerr << "Couldn't display dialog 'tradedialog.xml': "
<< e.what() << "\n";
return;
}
// set Dialog to Market-Data
Paragraph* p = getParagraph( *myDialogComponent, "DialogTitle" );
std::stringstream title;
title << _("Market") << " ( " << pointX <<" , " << pointY << " )";
p->setText( title.str() );
CheckButton* cb;
cb = getCheckButton( *myDialogComponent, "BuyJobs" );
if( MP_INFO( pointX,pointY ).flags & FLAG_MB_JOBS ) cb->check(); else cb->uncheck();
cb = getCheckButton( *myDialogComponent, "SellJobs" );
if( MP_INFO( pointX,pointY ).flags & FLAG_MS_JOBS ) cb->check(); else cb->uncheck();
cb = getCheckButton( *myDialogComponent, "BuyFood" );
if( MP_INFO( pointX,pointY ).flags & FLAG_MB_FOOD) cb->check(); else cb->uncheck();
cb = getCheckButton( *myDialogComponent, "SellFood" );
if( MP_INFO( pointX,pointY ).flags & FLAG_MS_FOOD) cb->check(); else cb->uncheck();
cb = getCheckButton( *myDialogComponent, "BuyCoal" );
if( MP_INFO( pointX,pointY ).flags & FLAG_MB_COAL) cb->check(); else cb->uncheck();
cb = getCheckButton( *myDialogComponent, "SellCoal" );
if( MP_INFO( pointX,pointY ).flags & FLAG_MS_COAL) cb->check(); else cb->uncheck();
cb = getCheckButton( *myDialogComponent, "BuyOre" );
if( MP_INFO( pointX,pointY ).flags & FLAG_MB_ORE) cb->check(); else cb->uncheck();
cb = getCheckButton( *myDialogComponent, "SellOre" );
if( MP_INFO( pointX,pointY ).flags & FLAG_MS_ORE) cb->check(); else cb->uncheck();
cb = getCheckButton( *myDialogComponent, "BuyGoods" );
if( MP_INFO( pointX,pointY ).flags & FLAG_MB_GOODS) cb->check(); else cb->uncheck();
cb = getCheckButton( *myDialogComponent, "SellGoods" );
if( MP_INFO( pointX,pointY ).flags & FLAG_MS_GOODS) cb->check(); else cb->uncheck();
cb = getCheckButton( *myDialogComponent, "BuySteel" );
if( MP_INFO( pointX,pointY ).flags & FLAG_MB_STEEL) cb->check(); else cb->uncheck();
cb = getCheckButton( *myDialogComponent, "SellSteel" );
if( MP_INFO( pointX,pointY ).flags & FLAG_MS_STEEL) cb->check(); else cb->uncheck();
// connect signals
Button* applyButton = getButton( *myDialogComponent, "Apply" );
applyButton->clicked.connect( makeCallback(*this, &Dialog::applyMarketButtonClicked ) );
Button* gotoButton = getButton( *myDialogComponent, "goto" );
gotoButton->clicked.connect( makeCallback( *this, &Dialog::gotoButtonClicked ) );
}
示例7: updateMoney
void updateMoney() {
if( lastMoney == total_money ){
return;
}
//Prevent overflow
if (total_money > 2000000000)
total_money = 2000000000;
else if (total_money < -2000000000)
total_money = -2000000000;
std::ostringstream moneyText;
int money = total_money;
if( abs(money) > 100000000 ){
moneyText << money/1000000 << _("M");
} else {
if( abs(money) > 1000000 ){
moneyText << money/1000000 << " ";
money %= 1000000;
money = abs(money);
moneyText << std::setw(6);
moneyText << std::setfill('0');
}
moneyText << money;
}
moneyText << _("$");
Component* root = getGameView();
if( !root ) return;
while( root->getParent() )
root = root->getParent();
Component* moneyParagraphComponent = 0;
moneyParagraphComponent = root->findComponent( "moneyParagraph" );
if( moneyParagraphComponent == 0 ) {
return;
}
Paragraph* moneyParagraph = getParagraph( *root, "moneyParagraph");
if( !moneyParagraph ) return;
moneyParagraph->setText( moneyText.str() );
lastMoney = total_money;
}
示例8: if
void
LCPBar::setValue(int num, int value, int diff)
{
std::ostringstream compname;
compname << "pbar_text" << (num+1);
Paragraph* p = getParagraph(*this, compname.str());
std::ostringstream os;
os<<std::fixed;
os<<std::setprecision(1);
if(num==PTECH)
{
os<<value/10000.0;
}
else if(num==PMONEY)
{
if(abs(value)>=1000000000)
os<<value/1000000<<"M";
else if(abs(value)>1000000)
os<<value/1000000.0<<"M";
else if(abs(value)>1000)
os<<value/1000.0<<"K";
else
os<<value;
}
else
os<<value;
if( diff != 0 ){
p->setText(os.str());
}
os.str("");
os<<"pbar_barview"<<(num+1);
float sv=0;
switch(num)
{
case PPOP:
sv=pbar_adjust_pop(diff);
break;
case PTECH:
sv=pbar_adjust_tech(diff);
break;
case PFOOD:
sv=pbar_adjust_food(diff);break;
case PJOBS:
sv=pbar_adjust_jobs(diff);break;
case PCOAL:
sv=pbar_adjust_coal(diff);break;
case PGOODS:
sv=pbar_adjust_goods(diff);break;
case PORE:
sv=pbar_adjust_ore(diff);break;
case PSTEEL:
sv=pbar_adjust_steel(diff);break;
case PMONEY:
sv=pbar_adjust_money(diff);break;
};
sv/=10.0;
if(sv>1.0)
sv=1.0;
if(sv<-1.0)
sv=-1.0;
Component *c=findComponent(os.str()+"a");
if(c)
{
BarView *bv=dynamic_cast<BarView*>(c);
if(bv)
{
bv->setValue(sv);
}
}
c=findComponent(os.str()+"b");
if(c)
{
BarView *bv=dynamic_cast<BarView*>(c);
if(bv)
{
bv->setValue(sv);
}
}
}
示例9: if
/*
static int Pbarorder[] = {
Construction::STUFF_FOOD,
Construction::STUFF_JOBS,
Construction::STUFF_GOODS,
Construction::STUFF_COAL,
Construction::STUFF_ORE,
Construction::STUFF_STEEL,
Construction::STUFF_WASTE,
Construction::STUFF_KWH,
Construction::STUFF_MWH,
Construction::STUFF_WATER,
};
*/
void
LCPBar::setValue(int num, int value, int diff)
{
if ((num > 8) && (pbarGlobalStyle == 0))
{ return;}
if ((pbarGlobalStyle == 1) && (num > 2) && (num < 9))
{ return;}
std::ostringstream os;
int line_number = num+1;
if ( (pbarGlobalStyle == 1) && (num>8))
{ line_number -= PBAR_PAGE_SHIFT;}
os << "pbar_text" << line_number;
Paragraph* p = getParagraph(*this, os.str());
os.str("");
//compname << "pbar_title" << line_number;
//Paragraph* pt = getParagraph(*this, compname.str());
if(num==PTECH)
{
os<<std::fixed;
os<<std::setprecision(1);
os<<value/10000.0;
}
else if(num==PMONEY || num==PPOP || num==PPOL)
{
char s[12];
num_to_ansi (s, sizeof(s), value);
os<<s;
}
else if ((num >= PFOOD) && (num <= PHOUSE)) //percentages
{
os<<value<<"%";
}
else
{
os<<"default";
}
if (p)
{ p->setText(os.str());}
float sv=0;
switch(num)
{
case PPOP:
sv = pbar_adjust_pop(diff);
break;
case PTECH:
sv = pbar_adjust_tech(diff);
break;
case PPOL:
sv = value<5000?100*diff/(1+value):value<25000?500*diff/value:5000*diff/value;
break;
case PMONEY:
sv = pbar_adjust_money(diff);
break;
default:
sv = diff;
break;
};
sv/=10.0;
if(sv>1.0)
sv=1.0;
if(sv<-1.0)
sv=-1.0;
os.str("");
os<<"pbar_barview"<< line_number;
Component *c=findComponent(os.str()+"a");
if(c)
{
BarView *bv=dynamic_cast<BarView*>(c);
if(bv)
{
bv->setValue(sv);
}
}
c=findComponent(os.str()+"b");
if(c)
{
BarView *bv=dynamic_cast<BarView*>(c);
if(bv)
//.........这里部分代码省略.........