本文整理汇总了C++中GuiText类的典型用法代码示例。如果您正苦于以下问题:C++ GuiText类的具体用法?C++ GuiText怎么用?C++ GuiText使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GuiText类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Assert
void GuiList::SetSelected(int child, bool selected)
{
Assert(child < GetNumChildren());
#ifdef LB_DEBUG
GuiText* text = dynamic_cast<GuiText*>(GetChild(child));
if (text)
{
std::cout << "List box " << m_name << ": " << text->GetText() << (selected ? " selected" : " UNselected") << "\n";
}
#endif
if (selected && !IsMultiSel())
{
// Not multi select, so at most one member in set.
for (SelSet::iterator it = m_selset.begin(); it != m_selset.end(); ++it)
{
int i = *it;
GetChild(i)->SetSelected(false);
}
m_selset.clear();
}
GetChild(child)->SetSelected(selected);
if (selected)
{
m_selset.insert(child);
}
else
{
m_selset.erase(child);
}
}
示例2: BLACK
void TrailCircle::Draw()
{
static GuiImage* circleImg = 0;
static GuiText text;
if (!circleImg)
{
circleImg = new GuiImage;
Texture* tex = (Texture*)TheResourceManager::Instance()->GetRes("circ1.png");
tex->SetFilter(AmjuGL::AMJU_TEXTURE_NICE);
circleImg->SetTexture(tex);
float aspect = (float)Screen::X() / (float)Screen::Y();
circleImg->SetSize(Vec2f(CIRCLE_SIZE, CIRCLE_SIZE * aspect));
text.SetSize(Vec2f(0.1f, 0.1f));
}
const Colour BLACK(0, 0, 0, 1);
const Colour WHITE(1, 1, 1, 1);
const Colour RED(1, 0, 0, 1);
circleImg->SetLocalPos(Vec2f(m_pos.x - CIRCLE_SIZE * 0.5f, m_pos.y + CIRCLE_SIZE * 0.5f));
PushColour();
MultColour(m_incorrect ? RED : (m_clicked ? BLACK : WHITE));
circleImg->Draw();
PopColour();
// Draw number/letter
text.SetSize(Vec2f(0.2f, 0.1f));
text.SetJust(GuiText::AMJU_JUST_CENTRE);
text.SetLocalPos(m_pos + Vec2f(-0.1f, 0.012f));
text.SetText(m_str);
text.SetFgCol(m_clicked || m_incorrect ? WHITE : BLACK);
text.Draw();
}
示例3: OnMsgRecv
void BroadcastConsole::OnMsgRecv(const std::string& str)
{
// Discard if same as last msg
if (!m_texts.empty())
{
if (m_texts[0]->GetText() == str)
{
std::cout << "Discarding duplicate msg\n";
return;
}
}
GuiText* text = new GuiText;
text->SetIsMulti(true);
text->SetTextSize(1.0f); // TODO CONFIG
text->SetSize(Vec2f(2.0f, 0.1f)); // assume single line
text->SetText(str);
text->SizeToText();
text->SetFgCol(Colour(1, 1, 0, 1));
m_texts.push_front(text);
static const unsigned int NUM_LINES = ROConfig()->GetInt("chat-max-lines", 10);
if (m_texts.size() > NUM_LINES)
{
m_texts.pop_back();
}
ReposText();
}
示例4: UpdateHeartCount
void GSGui::UpdateHeartCount()
{
if (m_gui)
{
GuiText* text = (GuiText*)GetElementByName(m_gui, "score-num");
if (text)
{
int h = 0;
if (GetPlayerCount(SCORE_KEY, &h))
{
text->SetText(ToString(h));
}
else
{
text->SetText("");
}
}
}
}
示例5: LoadGui
void GSYesNo::OnActive()
{
GSGui::OnActive();
m_gui = LoadGui("gui-yesno.txt");
Assert(m_gui);
GuiButton* yes = (GuiButton*)GetElementByName(m_gui, "yes-button");
yes->SetCommand(Amju::OnYes);
yes->SetHasFocus(true);
yes->SetText(m_yesText);
GuiButton* no = (GuiButton*)GetElementByName(m_gui, "no-button");
no->SetCommand(Amju::OnNo);
no->SetIsCancelButton(true);
no->SetText(m_noText);
GuiText* q = (GuiText*)GetElementByName(m_gui, "question");
q->SetText(m_question);
}
示例6: OnFinishedChecking
void GSFileUpdateCheck::OnDownloadedFile(const std::string& filename)
{
// If we are no longer the current state, it doesn't matter
if (TheGame::Instance()->GetState() != this)
{
return;
}
m_numFilesDownloaded++;
if (m_numFilesDownloaded >= m_numFilesToWaitFor)
{
// Done! Update to new timestamp
OnFinishedChecking(m_newtimestamp);
if (m_gui)
{
GuiText* t = (GuiText*)GetElementByName(m_gui, "filename");
t->SetText(filename);
}
}
}
示例7: Assert
void Hud::UpdateScores()
{
// Names of gui elements in hud gui text file
const char* GUI_NAME[2][2] =
{
{ "p1-score-text", "p1-lives-text" },
{ "p2-score-text", "p2-lives-text" }
};
for (int i = 0; i < 2; i++)
{
PlayerNum pn = (PlayerNum)i;
int score = TheScores::Instance()->GetScore(pn);
GuiText* t = (GuiText*)m_gui->GetElementByName(GUI_NAME[i][0]);
Assert(t);
t->SetText(ToString(score));
int lives = TheScores::Instance()->GetLives(pn);
t = (GuiText*)m_gui->GetElementByName(GUI_NAME[i][1]);
Assert(t);
t->SetText(ToString(lives));
}
int hiScore = TheScores::Instance()->GetHiScore();
GuiText* t = (GuiText*)m_gui->GetElementByName("hi-score-text");
Assert(t);
t->SetText(ToString(hiScore));
t = (GuiText*)m_gui->GetElementByName("hi-name-text");
Assert(t);
t->SetText(TheScores::Instance()->GetHiScoreName());
}
示例8: LoadGui
void GSNetError::OnActive()
{
GSGui::OnActive();
m_gui = LoadGui("gui-error.txt");
Assert(m_gui);
//// m_gui->GetElementByName("error-ok-button")->SetCommand(Amju::OnErrorOk);
//// m_gui->GetElementByName("error-quit-button")->SetCommand(Amju::OnErrorQuit);
GuiButton* ok = (GuiButton*)GetElementByName(m_gui, "error-ok-button");
ok->SetCommand(Amju::OnErrorOk);
ok->SetHasFocus(true);
GuiButton* quit = (GuiButton*)GetElementByName(m_gui, "error-quit-button");
quit->SetCommand(Amju::OnErrorQuit);
quit->SetIsCancelButton(true);
GuiText* t = dynamic_cast<GuiText*>(m_gui->GetElementByName("error"));
Assert(t);
t->SetText(m_errorStr);
}
示例9: GuiImage
void IconEmuMiiBrowser::AddButton()
{
//!File Icon
GuiImage * BtnImg = new GuiImage(fileMii);
BtnImg->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
BtnImg->SetPosition(0, 10);
ButtonImg.push_back(BtnImg);
//!File Name
GuiText * BtnTxt = new GuiText((char *) NULL, 14, (GXColor){0, 0, 0, 255});
BtnTxt->SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM);
BtnTxt->SetPosition(0, -20);
BtnTxt->SetLinesToDraw(2);
BtnTxt->SetMaxWidth(75, WRAP);
ButtonText.push_back(BtnTxt);
//!selection img
GuiImage * Marker = new GuiImage(bgSelectionEntry);
Marker->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
Marker->SetPosition(0, -7);
FileSelectionImg.push_back(Marker);
//!tooltip
GuiTooltip * tmpToolTip = new GuiTooltip((char *) NULL);
tmpToolTip->SetPosition(0, 0);
Tooltip.push_back(tmpToolTip);
GuiButton * Btn = new GuiButton(90, 90);
Btn->SetParent(this);
Btn->SetLabel(BtnTxt);
Btn->SetIcon(BtnImg);
Btn->SetImageOver(Marker);
Btn->SetTrigger(trigA);
Btn->SetSoundClick(btnSoundClick);
Btn->SetToolTip(tmpToolTip, 0, 0, ALIGN_CENTRE, ALIGN_TOP);
Buttons.push_back(Btn);
}
示例10: Draw
virtual void Draw()
{
// Don't draw name of local player ?
if (IsVisible() && m_player->GetId() != GetLocalPlayerId())
{
//Assert(m_player->GetAABB());
//DrawAABB(*(m_player->GetAABB()));
// Print name
// TODO Do all these in one go, to minimise state changes
AmjuGL::PushAttrib(AmjuGL::AMJU_BLEND | AmjuGL::AMJU_DEPTH_READ);
AmjuGL::Enable(AmjuGL::AMJU_BLEND);
AmjuGL::Disable(AmjuGL::AMJU_DEPTH_READ);
GuiText text;
text.SetTextSize(5.0f); // TODO CONFIG
text.SetText(m_player->GetName());
static const float MAX_NAME_WIDTH = 4.0f; // minimise this to reduce overdraw - calc from text
text.SetSize(Vec2f(MAX_NAME_WIDTH, 1.0f));
text.SetJust(GuiText::AMJU_JUST_CENTRE);
//text.SetInverse(true);
//text.SetDrawBg(true);
text.SetFgCol(Colour(1, 1, 1, 1));
AmjuGL::PushMatrix();
Matrix m;
m.SetIdentity();
// Reverse modelview rotation
Matrix r;
r.ModelView();
m = TransposeRot(r);
Vec3f tr(m_combined[12], m_combined[13], m_combined[14]);
m.TranslateKeepRotation(tr);
AmjuGL::MultMatrix(m);
static const float SCALE_FACTOR = 20.0f;
float x = MAX_NAME_WIDTH * SCALE_FACTOR * -0.5f;
AmjuGL::Translate(x, 60.0f, 0); // TODO CONFIG
AmjuGL::Scale(SCALE_FACTOR, SCALE_FACTOR, 10);
text.Draw();
AmjuGL::PopMatrix();
AmjuGL::PopAttrib();
}
}
示例11: Set
void LurkMsg::Set(const std::string& str, const Colour& fgCol, const Colour& bgCol, LurkPos lp,
CommandFunc onFinished)
{
GuiText* text = new GuiText;
if (lp == AMJU_CENTRE)
{
text->SetIsMulti(true);
}
text->SetTextSize(1.5f); // TODO CONFIG
text->SetSize(Vec2f(1.6f, 0.1f)); // assume single line
text->SetText(str);
text->SizeToText();
text->SetFgCol(fgCol);
Set(text, fgCol, bgCol, lp, onFinished);
}
示例12: SetLevel
void Hud::SetLevel(int level)
{
GuiText* t = (GuiText*)m_gui->GetElementByName("level-num");
Assert(t);
t->SetText(ToString(level));
}
示例13: GuiText
void GuiArrowOption::AddOption(const char * name, int PositionX, int PositionY)
{
int Center = PositionX;
GuiText * OptName = new GuiText(name, 16, (GXColor) {
0, 0, 0, 255
});
OptName->SetAlignment(ALIGN_LEFT | ALIGN_TOP);
OptName->SetPosition(Center-OptName->GetTextWidth()/2, PositionY);
GuiText * OptText = new GuiText(" ", 16, (GXColor) {
0, 0, 0, 255
});
OptText->SetPosition(Center-OptText->GetTextWidth()/2, PositionY+30);
OptText->SetAlignment(ALIGN_LEFT | ALIGN_TOP);
GuiButton * OptBtn = new GuiButton(OptName->GetTextWidth(), 18);
OptBtn->SetSoundOver(btnSoundOver);
OptBtn->SetSoundClick(btnClick);
OptBtn->SetTrigger(trigA);
OptBtn->SetPosition(Center-OptText->GetTextWidth()/2, PositionY+30);
OptBtn->SetAlignment(ALIGN_LEFT | ALIGN_TOP);
OptBtn->Clicked.connect(this, &GuiArrowOption::OnButtonClick);
GuiImage * OptImgLeft = new GuiImage(ArrowImgData);
OptImgLeft->SetAngle(180);
GuiButton * OptBtnLeft = new GuiButton(OptImgLeft->GetWidth(), OptImgLeft->GetHeight());
OptBtnLeft->SetImage(OptImgLeft);
OptBtnLeft->SetSoundOver(btnSoundOver);
OptBtnLeft->SetSoundClick(btnClick);
OptBtnLeft->SetTrigger(trigA);
OptBtnLeft->SetEffectGrow();
OptBtnLeft->SetPosition(Center-(OptText->GetTextWidth()/2+10), PositionY+30);
OptBtnLeft->SetAlignment(ALIGN_LEFT | ALIGN_TOP);
OptBtnLeft->Clicked.connect(this, &GuiArrowOption::OnLeftButtonClick);
GuiImage * OptImgRight = new GuiImage(ArrowImgData);
GuiButton * OptBtnRight = new GuiButton(OptImgRight->GetWidth(), OptImgRight->GetHeight());
OptBtnRight->SetImage(OptImgRight);
OptBtnRight->SetSoundOver(btnSoundOver);
OptBtnRight->SetSoundClick(btnClick);
OptBtnRight->SetTrigger(trigA);
OptBtnRight->SetEffectGrow();
OptBtnRight->SetPosition(Center+(OptText->GetTextWidth()/2+10), PositionY+30);
OptBtnRight->SetAlignment(ALIGN_LEFT | ALIGN_TOP);
OptBtnRight->Clicked.connect(this, &GuiArrowOption::OnRightButtonClick);
Append(OptName);
Append(OptText);
Append(OptBtn);
Append(OptBtnLeft);
Append(OptBtnRight);
OptionsName.push_back(OptName);
OptionsText.push_back(OptText);
OptionsBtn.push_back(OptBtn);
OptionsImgLeft.push_back(OptImgLeft);
OptionsBtnLeft.push_back(OptBtnLeft);
OptionsImgRight.push_back(OptImgRight);
OptionsBtnRight.push_back(OptBtnRight);
}
示例14: ToString
void GSMain::Draw2d()
{
AmjuGL::Viewport(0, 0, Screen::X(), Screen::Y());
TheHud::Instance()->Draw();
// Store scaled modelview matrix
float mat[16];
AmjuGL::GetMatrix(AmjuGL::AMJU_MODELVIEW_MATRIX, mat);
// Split screen -- draw all screens
int numVps = TheViewportManager::Instance()->GetNumViewports();
for (int i = 0; i < numVps; i++)
{
AmjuGL::SetMatrixMode(AmjuGL::AMJU_MODELVIEW_MATRIX);
AmjuGL::SetIdentity();
// Restore scaled mv matrix
AmjuGL::MultMatrix(mat);
TheViewportManager::Instance()->GetViewport(i)->Draw2d();
}
m_gui->Draw(); // split screen line etc
TheLurker::Instance()->Draw();
#ifdef GEKKO
TheCursorManager::Instance()->Draw();
#endif
#ifdef SHOW_INFO
// TODO Switch on/off
if (true)
{
static GuiText t;
t.SetFgCol(Colour(1, 1, 1, 1));
t.SetBgCol(Colour(0, 0, 0, 1));
t.SetDrawBg(true);
t.SetFontSize(0.8f); // TODO CONFIG
t.SetIsMulti(true);
t.SetLocalPos(Vec2f(-1.0f, -0.8f));
t.SetSize(Vec2f(1.0f, 0.2f));
t.SetJust(GuiText::AMJU_JUST_LEFT);
float playerX = Player::GetPlayer(AMJU_P1)->GetPos().x;
static std::string old;
std::string s = "Depth: " + ToString((int)GetCurrentDepth()) +
" X: " + ToString((int)playerX) +
"\nNum Game Objects: " +
ToString((int)TheGame::Instance()->GetGameObjects()->size());
if (old != s)
{
t.SetText(s);
}
old = s;
t.Draw();
}
#endif // SHOW_INFO
}
示例15: GetAppName
void GSTitle::Draw2d()
{
GSGui::Draw2d();
#ifdef SHOW_ENV_INFO
// Draw env info, etc.
static GuiText t;
t.SetSize(Vec2f(1.0f, 0.1f));
t.SetJust(GuiText::AMJU_JUST_LEFT);
t.SetDrawBg(true);
t.SetLocalPos(Vec2f(-1.0f, 0.8f));
std::string s = "SaveDir: " + GetAppName();
t.SetText(s);
t.Draw();
t.SetLocalPos(Vec2f(-1.0f, 0.7f));
s = "Server: " + GetServer();
t.SetText(s);
t.Draw();
t.SetLocalPos(Vec2f(-1.0f, 0.6f));
s = "Env: " + GetEnv();
t.SetText(s);
t.Draw();
#endif
}