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(); }
// 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); } }
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) || static_cast<unsigned>(selectedRow) >= player.Accounts().Mortgages().size()); if(isSelected) table.DrawHighlight(back); table.Draw(amount, unselected); if(qualify) { table.Advance(4); table.Draw("[apply]", selected); } const Interface *interface = GameData::Interfaces().Get("bank"); Information info; for(const Mortgage &mortgage : player.Accounts().Mortgages()) if(mortgage.Principal() <= player.Accounts().Credits()) info.SetCondition("can pay"); interface->Draw(info); }
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); zones.emplace_back(table.GetCenterPoint(), table.GetRowSize(), command); table.Draw(command.Description(), medium); table.Draw(command.KeyName(), isEditing ? bright : medium); } } Table shiftTable; shiftTable.AddColumn(125, Table::RIGHT); shiftTable.SetUnderline(0, 130); shiftTable.DrawAt(Point(-400, 52)); shiftTable.DrawUnderline(medium); shiftTable.Draw("With <shift> key", bright); shiftTable.DrawGap(5); shiftTable.Draw("Select nearest ship", medium); shiftTable.Draw("Select next escort", medium); shiftTable.Draw("Talk to planet", medium); shiftTable.Draw("Board disabled escort", medium); }