本文整理汇总了C++中Table::SetHighlight方法的典型用法代码示例。如果您正苦于以下问题:C++ Table::SetHighlight方法的具体用法?C++ Table::SetHighlight怎么用?C++ Table::SetHighlight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Table
的用法示例。
在下文中一共展示了Table::SetHighlight方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Draw
Point ItemInfoDisplay::Draw(Point point, const vector<string> &labels, const vector<string> &values) const
{
// Add ten pixels of padding at the top.
point.Y() += 10.;
// Get standard colors to draw with.
Color labelColor = *GameData::Colors().Get("medium");
Color valueColor = *GameData::Colors().Get("bright");
Table table;
// Use 10-pixel margins on both sides.
table.AddColumn(10, Table::LEFT);
table.AddColumn(WIDTH - 10, Table::RIGHT);
table.SetHighlight(0, WIDTH);
table.DrawAt(point);
for(unsigned i = 0; i < labels.size() && i < values.size(); ++i)
{
if(labels[i].empty())
{
table.DrawGap(10);
continue;
}
CheckHover(table, labels[i]);
table.Draw(labels[i], values[i].empty() ? valueColor : labelColor);
table.Draw(values[i], valueColor);
}
return table.GetPoint();
}
示例2: DrawAttributes
// Draw each of the panels.
void ShipInfoDisplay::DrawAttributes(const Point &topLeft) const
{
Point point = Draw(topLeft, attributeLabels, attributeValues);
// Get standard colors to draw with.
Color labelColor = *GameData::Colors().Get("medium");
Color valueColor = *GameData::Colors().Get("bright");
Table table;
table.AddColumn(10, Table::LEFT);
table.AddColumn(WIDTH - 90, Table::RIGHT);
table.AddColumn(WIDTH - 10, Table::RIGHT);
table.SetHighlight(0, WIDTH);
table.DrawAt(point);
table.DrawGap(10.);
table.Advance();
table.Draw("energy", labelColor);
table.Draw("heat", labelColor);
for(unsigned i = 0; i < tableLabels.size(); ++i)
{
CheckHover(table, tableLabels[i]);
table.Draw(tableLabels[i], labelColor);
table.Draw(energyTable[i], valueColor);
table.Draw(heatTable[i], valueColor);
}
}
示例3: Draw
void BankPanel::Draw() const
{
Table table;
table.AddColumn(TYPE_X, Table::LEFT);
table.AddColumn(PRINCIPAL_X, Table::LEFT);
table.AddColumn(INTEREST_X, Table::LEFT);
table.AddColumn(TERM_X, Table::LEFT);
table.AddColumn(PAYMENT_X, Table::LEFT);
table.AddColumn(170, Table::RIGHT);
table.SetHighlight(-300, 180);
table.DrawAt(Point(0., FIRST_Y));
Color back = *GameData::Colors().Get("faint");
Color unselected = *GameData::Colors().Get("medium");
Color selected = *GameData::Colors().Get("bright");
table.DrawUnderline(unselected);
table.SetColor(selected);
for(int i = 0; i < 6; ++i)
table.Draw(HEADING[i]);
table.DrawGap(5);
// Figure out the total payments and principal (other than salaries). This
// is in case there are more mortgages than can be displayed.
int otherPrincipal = 0;
int otherPayment = 0;
for(const Mortgage &mortgage : player.Accounts().Mortgages())
{
otherPrincipal += mortgage.Principal();
otherPayment += mortgage.Payment();
}
int totalPayment = otherPayment;
// Check if salaries need to be drawn.
int salaries = player.Salaries();
int row = 0;
for(const Mortgage &mortgage : player.Accounts().Mortgages())
{
if(row == selectedRow)
{
table.DrawHighlight(back);
table.SetColor(selected);
}
else
table.SetColor(unselected);
// There is room for seven rows if including salaries, or 8 if not.
if(row == (6 + !salaries) && otherPrincipal != mortgage.Principal())
{
table.Draw("Other", unselected);
table.Draw(otherPrincipal);
table.Advance(2);
table.Draw(otherPayment);
}
else
{
table.Draw(mortgage.Type());
table.Draw(mortgage.Principal());
table.Draw(mortgage.Interest());
table.Draw(mortgage.Term());
table.Draw(mortgage.Payment());
otherPrincipal -= mortgage.Principal();
otherPayment -= mortgage.Payment();
}
table.Draw("[pay extra]");
++row;
// Draw no more than 8 rows, counting the salaries row if any.
if(row == 7 + !salaries)
break;
}
table.SetColor(unselected);
// Draw the salaries, if necessary.
if(salaries)
{
totalPayment += salaries;
table.Draw("Crew Salaries", unselected);
table.Advance(3);
table.Draw(salaries);
table.Advance();
}
table.Advance(3);
table.Draw("total:", selected);
table.Draw(totalPayment, unselected);
table.Advance();
table.DrawAt(Point(0., FIRST_Y + 210.));
string credit = "Your credit score is " + to_string(player.Accounts().CreditScore()) + ".";
table.Draw(credit);
table.Advance(5);
string amount;
if(!qualify)
amount = "You do not qualify for further loans at this time.";
else
amount = "You qualify for a new loan of up to " + Format::Number(qualify) + " credits.";
bool isSelected = qualify && (selectedRow > (6 + !salaries)
//.........这里部分代码省略.........
示例4: DrawControls
void PreferencesPanel::DrawControls()
{
const Color &back = *GameData::Colors().Get("faint");
const Color &dim = *GameData::Colors().Get("dim");
const Color &medium = *GameData::Colors().Get("medium");
const Color &bright = *GameData::Colors().Get("bright");
// Check for conflicts.
Color red(.3, 0., 0., .3);
Table table;
table.AddColumn(-115, Table::LEFT);
table.AddColumn(115, Table::RIGHT);
table.SetUnderline(-120, 120);
int firstY = -248;
table.DrawAt(Point(-130, firstY));
static const string CATEGORIES[] = {
"Navigation",
"Weapons",
"Targeting",
"Menus",
"Fleet"
};
const string *category = CATEGORIES;
static const Command COMMANDS[] = {
Command::NONE,
Command::FORWARD,
Command::LEFT,
Command::RIGHT,
Command::BACK,
Command::AFTERBURNER,
Command::LAND,
Command::JUMP,
Command::NONE,
Command::PRIMARY,
Command::SELECT,
Command::SECONDARY,
Command::CLOAK,
Command::NONE,
Command::NEAREST,
Command::TARGET,
Command::HAIL,
Command::BOARD,
Command::SCAN,
Command::NONE,
Command::MENU,
Command::MAP,
Command::INFO,
Command::FULLSCREEN,
Command::NONE,
Command::DEPLOY,
Command::FIGHT,
Command::GATHER,
Command::HOLD,
Command::AMMO
};
static const Command *BREAK = &COMMANDS[19];
for(const Command &command : COMMANDS)
{
// The "BREAK" line is where to go to the next column.
if(&command == BREAK)
table.DrawAt(Point(130, firstY));
if(!command)
{
table.DrawGap(10);
table.DrawUnderline(medium);
if(category != end(CATEGORIES))
table.Draw(*category++, bright);
else
table.Advance();
table.Draw("Key", bright);
table.DrawGap(5);
}
else
{
int index = zones.size();
// Mark conflicts.
bool isConflicted = command.HasConflict();
bool isEditing = (index == editing);
if(isConflicted || isEditing)
{
table.SetHighlight(66, 120);
table.DrawHighlight(isEditing ? dim: red);
}
// Mark the selected row.
bool isHovering = (index == hover && !isEditing);
if(!isHovering && index == selected)
{
table.SetHighlight(-120, 64);
table.DrawHighlight(back);
}
// Highlight whichever row the mouse hovers over.
table.SetHighlight(-120, 120);
if(isHovering)
table.DrawHighlight(back);
//.........这里部分代码省略.........