|
Player12
An open source football management simulator
|
Small vector icons drawn with ImDrawList (no icon font needed). More...
Namespaces | |
| namespace | Size |
| Design-system sizes in unscaled pixels. | |
Classes | |
| struct | BarDatum |
| One bar in a horizontal bar chart. More... | |
| struct | Column |
| One column of a responsive table. More... | |
| struct | MoneyChip |
| A quick-pick value offered under a money input. More... | |
| struct | MoneyInputOptions |
| Options of moneyInput(). More... | |
| struct | MoneyPreview |
| Line shown under a money input while typing. More... | |
| class | TileRow |
| Lays out a row of equal tiles that wraps onto more lines when the region is too narrow for them all (small windows, large UI scale). More... | |
Typedefs | |
| using | ColumnMask = uint32_t |
| Visible-column mask produced by fitColumns(). | |
Enumerations | |
| enum class | Icon : uint8_t { HOME , SQUAD , LINEUP , TACTICS , FIXTURES , STANDINGS , TRANSFERS , FINANCES , SAVE , SETTINGS , EXIT , SEARCH , EDIT , INBOX , CLUB } |
| Available icons. More... | |
| enum class | DialogResult : uint8_t { NONE , CONFIRM , CANCEL } |
| Result of a modal confirmation dialog. More... | |
| enum class | Outcome : uint8_t { WIN , DRAW , LOSS } |
| Match outcome for form strips. More... | |
| enum class | ButtonSize : uint8_t { REGULAR , COMPACT } |
| Button height class. More... | |
| enum class | TableHeader : uint8_t { STATIC , SORTABLE , NONE } |
| Header row emitted by beginResponsiveTable(). More... | |
Functions | |
| void | drawIcon (ImDrawList *drawList, Icon icon, ImVec2 center, float size, ImU32 color) |
| Draws an icon centred on a point. | |
| bool | drawTextFitted (ImDrawList *drawList, ImVec2 position, ImU32 color, std::string_view text, float maxWidth) |
| Draws text cut to maxWidth with a trailing ellipsis when needed. | |
| void | textFitted (std::string_view text, float maxWidth, const ImVec4 &color) |
| Text item limited to maxWidth; shows the full text as a tooltip when it had to be shortened. | |
| void | pageHeader (const char *title, const char *subtitle=nullptr) |
| Large page title with an optional muted subtitle. | |
| void | sectionLabel (const char *text) |
| Small uppercase section label. | |
| void | beginCard (const char *id, const char *title, ImVec2 size, bool scroll=false) |
| Starts a bordered card. Always pair with endCard(). | |
| void | beginAutoHeightCard (const char *id, const char *title, float width=0.0f) |
| Starts a card that grows to fit its content (never scrolls). | |
| void | endCard () |
| Ends a card started with beginCard() or beginAutoHeightCard(). | |
| float | statTileHeight () |
| Height used by statTile(), for layout calculations. | |
| void | statTile (const char *id, const char *caption, const char *value, const char *footnote, const ImVec4 &valueColor, float width) |
| Figure tile: caption, big value and an optional footnote. | |
| void | attributeBar (const char *label, float value, float labelWidth, float maxValue=100.0f, float width=0.0f) |
| Labelled horizontal bar coloured with the rating scale. | |
| void | meter (const char *label, float fraction, float labelWidth, const ImVec4 &color, const char *valueText) |
| Labelled bar with an explicit colour and value text (0-1). | |
| void | ratingChip (double rating) |
| Rounded rating chip, coloured by the rating scale. | |
| void | badge (const char *text, const ImVec4 &color) |
| Small coloured badge with text. | |
| void | drawClubBadge (ImDrawList *drawList, ImVec2 min, float height, const char *code, uint32_t primary, uint32_t secondary) |
| clubBadge() drawn at a position (height in pixels), no layout. | |
| void | clubBadge (const char *code, uint32_t primary, uint32_t secondary, float height) |
| Two-colour club shield (kit colours 0xRRGGBB) with the short code drawn inside when the shield is tall enough to read it. | |
| void | formStrip (std::span< const Outcome > outcomes) |
| Row of W/D/L markers (latest last). | |
| void | emptyState (const char *title, const char *body) |
| Muted placeholder shown when a list has nothing to display. | |
| DialogResult | confirmDialog (const char *id, const char *title, const char *body, const char *confirmLabel, const char *cancelLabel) |
| Modal confirmation. Open with ImGui::OpenPopup(id) beforehand. | |
| void | sparkline (const char *id, std::span< const float > values, ImVec2 size, const ImVec4 &color) |
| Line chart of a series in a fixed box. | |
| void | deltaBars (const char *id, std::span< const float > values, ImVec2 size) |
| Bars above/below a zero line (positive green, negative red). | |
| void | barChart (const char *id, std::span< const BarDatum > bars, float width, float labelWidth) |
| Horizontal bars with labels and values, scaled to the maximum. | |
| bool | beginDataTable (const char *id, int columns, ImGuiTableFlags flags, float minWidth, ImVec2 size, int freezeColumns=1) |
| Begins a data table that scrolls horizontally only when the region is narrower than minWidth, freezing the header row (and freezeColumns leading columns while scrolling). Pair with ImGui::EndTable() when true. | |
| void | staticHeadersRow () |
| Header row of a non-sortable table: plain labels without the hover highlight that suggests a clickable header. | |
| int64_t | stepMoney (int64_t value, bool up, double fraction) |
Next value of a money input's -/+ button: fraction up or down, rounded to three significant figures, and always at least 1 away. | |
| float | buttonHeight (ButtonSize buttonSize=ButtonSize::REGULAR) |
| Scaled height of a button class. | |
| bool | primaryButton (const char *label, ImVec2 size=ImVec2(0, 0), ButtonSize buttonSize=ButtonSize::REGULAR) |
| Accent-filled call-to-action button. | |
| bool | secondaryButton (const char *label, ImVec2 size=ImVec2(0, 0), ButtonSize buttonSize=ButtonSize::REGULAR) |
| Neutral button for secondary actions. | |
| bool | dangerButton (const char *label, ImVec2 size=ImVec2(0, 0), ButtonSize buttonSize=ButtonSize::REGULAR) |
| Red button for destructive actions (release, cancel contract). | |
| bool | parseMoney (std::string_view text, int64_t &value) |
| Parses "14.4M", "1,5M", "850k", "€1,200,000", "€ 2,25 mln" (false when invalid or ambiguous; see NumberFormat::parseMoney()). | |
| MoneyPreview | moneyPreview (std::string_view text, const MoneyInputOptions &options={}) |
What moneyInput() shows for the typed text. | |
| bool | moneyInput (const char *id, int64_t &value, const MoneyInputOptions &options={}) |
| Currency field showing the full amount; typing accepts plain numbers, either decimal mark and k/M/B (mila/mln/mld) units, with the reading or the reason for refusing it shown under the field. -/+ step 5% (Shift 10%, Ctrl 1%), chips set preset values. | |
| bool | toggleButton (const char *label, bool active, ImVec2 size=ImVec2(0, 0), ButtonSize buttonSize=ButtonSize::REGULAR) |
| Filter/tab button: neutral when off, selection fill with an accent underline when on (one segment of UI::segmented()). | |
| bool | segmented (const char *id, int &selected, std::span< const char *const > labels, float width=0.0f) |
| Segmented control for small enumerations (joined buttons). | |
| void | summaryRow (const char *label, const char *value, const ImVec4 *valueColor=nullptr, bool emphasis=false) |
| Label on the left, value right-aligned; emphasis draws a rule above and a larger value (totals). | |
| void | budgetImpact (const char *label, int64_t current, int64_t after, const char *reasonWhenNegative=nullptr) |
| Budget before/after bar: "€20.0M -> €5.6M" (drawn arrow). The after part turns red below zero and the reason is shown underneath. | |
| ColumnMask | fitColumns (std::span< const Column > columns, float availableWidth, float stretchMinimum=160.0f, ColumnMask hidden=0) |
| Chooses the columns that fit the available width, dropping the highest priority numbers first (never horizontal scrolling). | |
| ColumnMask | hiddenColumns (std::string_view table, std::span< const Column > columns) |
| Columns the user hid in a table, saved in the settings per table. | |
| bool | columnPicker (std::string_view table, std::span< const Column > columns, ColumnMask fitted) |
| "Columns" button opening a checklist of the table's columns; the choice is saved in the settings at once. Priority-0 columns are listed but locked; columns that are on but squeezed out by the window width are marked as such. | |
| bool | beginResponsiveTable (const char *id, std::span< const Column > columns, ColumnMask mask, ImGuiTableFlags flags, TableHeader header=TableHeader::STATIC, ImVec2 size=ImVec2(0, 0)) |
| BeginTable + setup of the visible columns and the header row. Pair with ImGui::EndTable() when it returns true. Re-opening the same id with TableHeader::NONE continues a table split around an inline detail strip (column widths stay shared). | |
| bool | cell (ColumnMask mask, int index) |
| Moves to the next cell when column index is visible. | |
| bool | link (const char *label, const char *id) |
| Selectable text that looks like a link; returns true on click. | |
| void | keyValue (const char *key, const char *value, float keyWidth) |
| Muted key on the left, value on the right of the current row. | |
| bool | sameLineIfFits (float nextWidth, float spacing=-1.0f) |
| SameLine() only when an item of the given width still fits. | |
| float | buttonWidth (const char *label, ButtonSize buttonSize=ButtonSize::REGULAR) |
| Width of a button with this label (at least the minimum width). | |
| void | textRight (const char *text) |
| Text right-aligned in the current table cell or content region. | |
| void | textRightColored (const ImVec4 &color, const char *text) |
| Coloured text right-aligned in the current cell. | |
| template<typename T > | |
| int | compare (const T &left, const T &right) |
| Strictly-weak three-way comparison helper for table sorting. | |
Small vector icons drawn with ImDrawList (no icon font needed).
Reusable, theme-aware widgets for management screens.
All widgets draw with the current Theme palette, never allocate per call beyond ImGui's own buffers, and keep ImGui's ID/layout semantics so they can be mixed freely with regular ImGui calls.
Quick reference (sizes are unscaled; widgets multiply by Theme::scale()):
Buttons (min height UI::Size::BUTTON = 36 px, COMPACT = 28 px for rows) if (UI::primaryButton("Submit offer")) ... // accent, main CTA if (UI::secondaryButton("Cancel")) ... // neutral if (UI::dangerButton("Release")) ... // destructive UI::secondaryButton("Hire", {}, UI::ButtonSize::COMPACT); // in tables size.x: 0 = fit label (>= BUTTON_MIN_WIDTH), -FLT_MIN = fill width.
Money and negotiation int64_t fee = 14'400'000; const UI::MoneyChip chips[] = {{"Asking", asking}, {"Value", value}}; if (UI::moneyInput("##fee", fee, {.minimum = 0, .chips = chips})) ... Shows "€14.4M"; accepts "15m", "850k", "1,200,000"; the -/+ buttons step 5% (Shift 10%, Ctrl 1%). int upfront = 2; // index into the labels const char* parts[] = {"20%", "40%", "60%", "80%", "100%"}; UI::segmented("##upfront", upfront, parts); UI::summaryRow("Transfer fee", "€14.4M"); UI::summaryRow("Total cost", "€21.0M", nullptr, true); // emphasis UI::budgetImpact("Transfer budget", budget, budget - fee, "Over budget");
Filters and tabs if (UI::toggleButton("Defenders", filter == DEF)) filter = DEF;
Layout (one scroll surface per page: the page scrolls, cards size to content; never nest scrolling tables inside fixed-height cards) UI::beginAutoHeightCard("id", "TITLE", width); ... UI::endCard(); A fixed-height card with a ScrollY table is only for layouts that fill the window exactly (the page itself must not scroll then).
Tables (no horizontal scrolling: low-priority columns hide instead) static const UI::Column COLUMNS[] = { {"Name", 0.0f, 0}, // width 0 = stretch; priority 0 = keep {"Age", 44.0f, 3}, // hides first {"Wage", 84.0f, 2}}; const UI::ColumnMask mask = UI::fitColumns(COLUMNS, ImGui::GetContentRegionAvail().x); if (UI::beginResponsiveTable("t", COLUMNS, mask, flags)) { ImGui::TableNextRow(); ImGui::TableNextColumn(); ... // column 0 always visible if (UI::cell(mask, 1)) ImGui::Text(...); ImGui::EndTable(); } Row actions go into a detail strip under the selected row: end the table, draw the strip, reopen the same id with UI::TableHeader::NONE.
| using UI::ColumnMask = typedef uint32_t |
Visible-column mask produced by fitColumns().
|
strong |
Button height class.
| Enumerator | |
|---|---|
| REGULAR | |
| COMPACT | |
|
strong |
|
strong |
|
strong |
Match outcome for form strips.
| Enumerator | |
|---|---|
| WIN | |
| DRAW | |
| LOSS | |
|
strong |
Header row emitted by beginResponsiveTable().
| Enumerator | |
|---|---|
| STATIC | Plain labels (non-sortable tables). |
| SORTABLE | ImGui header row with sort arrows. |
| NONE | No header: continuation of a split table. |
| void UI::attributeBar | ( | const char * | label, |
| float | value, | ||
| float | labelWidth, | ||
| float | maxValue = 100.0f, |
||
| float | width = 0.0f |
||
| ) |
Labelled horizontal bar coloured with the rating scale.
| width | Total row width; 0 uses the available width. |
| void UI::badge | ( | const char * | text, |
| const ImVec4 & | color | ||
| ) |
Small coloured badge with text.
| void UI::barChart | ( | const char * | id, |
| std::span< const BarDatum > | bars, | ||
| float | width, | ||
| float | labelWidth | ||
| ) |
Horizontal bars with labels and values, scaled to the maximum.
| void UI::beginAutoHeightCard | ( | const char * | id, |
| const char * | title, | ||
| float | width = 0.0f |
||
| ) |
Starts a card that grows to fit its content (never scrolls).
| width | Card width (0 = the full available width). |
| void UI::beginCard | ( | const char * | id, |
| const char * | title, | ||
| ImVec2 | size, | ||
| bool | scroll = false |
||
| ) |
Starts a bordered card. Always pair with endCard().
| id | Stable ImGui id. |
| title | Optional caption drawn at the top of the card. |
| size | Card size (0 = fill available on that axis). |
| scroll | Allow the card body to scroll. |
| bool UI::beginDataTable | ( | const char * | id, |
| int | columns, | ||
| ImGuiTableFlags | flags, | ||
| float | minWidth, | ||
| ImVec2 | size, | ||
| int | freezeColumns | ||
| ) |
Begins a data table that scrolls horizontally only when the region is narrower than minWidth, freezing the header row (and freezeColumns leading columns while scrolling). Pair with ImGui::EndTable() when true.
| bool UI::beginResponsiveTable | ( | const char * | id, |
| std::span< const Column > | columns, | ||
| ColumnMask | mask, | ||
| ImGuiTableFlags | flags, | ||
| TableHeader | header, | ||
| ImVec2 | size | ||
| ) |
BeginTable + setup of the visible columns and the header row. Pair with ImGui::EndTable() when it returns true. Re-opening the same id with TableHeader::NONE continues a table split around an inline detail strip (column widths stay shared).
| void UI::budgetImpact | ( | const char * | label, |
| int64_t | current, | ||
| int64_t | after, | ||
| const char * | reasonWhenNegative | ||
| ) |
Budget before/after bar: "€20.0M -> €5.6M" (drawn arrow). The after part turns red below zero and the reason is shown underneath.
| float UI::buttonHeight | ( | ButtonSize | buttonSize | ) |
Scaled height of a button class.
| float UI::buttonWidth | ( | const char * | label, |
| ButtonSize | buttonSize | ||
| ) |
Width of a button with this label (at least the minimum width).
| bool UI::cell | ( | ColumnMask | mask, |
| int | index | ||
| ) |
Moves to the next cell when column index is visible.
| void UI::clubBadge | ( | const char * | code, |
| uint32_t | primary, | ||
| uint32_t | secondary, | ||
| float | height | ||
| ) |
Two-colour club shield (kit colours 0xRRGGBB) with the short code drawn inside when the shield is tall enough to read it.
| height | Unscaled shield height; the width follows (0.84 ratio). |
| bool UI::columnPicker | ( | std::string_view | table, |
| std::span< const Column > | columns, | ||
| ColumnMask | fitted | ||
| ) |
"Columns" button opening a checklist of the table's columns; the choice is saved in the settings at once. Priority-0 columns are listed but locked; columns that are on but squeezed out by the window width are marked as such.
| columns | Columns with untranslated label keys. |
| fitted | Visible mask from fitColumns(). |
| int UI::compare | ( | const T & | left, |
| const T & | right | ||
| ) |
Strictly-weak three-way comparison helper for table sorting.
| DialogResult UI::confirmDialog | ( | const char * | id, |
| const char * | title, | ||
| const char * | body, | ||
| const char * | confirmLabel, | ||
| const char * | cancelLabel | ||
| ) |
Modal confirmation. Open with ImGui::OpenPopup(id) beforehand.
| bool UI::dangerButton | ( | const char * | label, |
| ImVec2 | size, | ||
| ButtonSize | buttonSize | ||
| ) |
Red button for destructive actions (release, cancel contract).
| void UI::deltaBars | ( | const char * | id, |
| std::span< const float > | values, | ||
| ImVec2 | size | ||
| ) |
Bars above/below a zero line (positive green, negative red).
| void UI::drawClubBadge | ( | ImDrawList * | drawList, |
| ImVec2 | min, | ||
| float | height, | ||
| const char * | code, | ||
| uint32_t | primary, | ||
| uint32_t | secondary | ||
| ) |
clubBadge() drawn at a position (height in pixels), no layout.
| void UI::drawIcon | ( | ImDrawList * | drawList, |
| Icon | icon, | ||
| ImVec2 | center, | ||
| float | size, | ||
| ImU32 | color | ||
| ) |
Draws an icon centred on a point.
| drawList | Target draw list. |
| icon | Icon to draw. |
| center | Centre in screen coordinates. |
| size | Icon box size in pixels. |
| color | Stroke colour. |
| bool UI::drawTextFitted | ( | ImDrawList * | drawList, |
| ImVec2 | position, | ||
| ImU32 | color, | ||
| std::string_view | text, | ||
| float | maxWidth | ||
| ) |
Draws text cut to maxWidth with a trailing ellipsis when needed.
| void UI::emptyState | ( | const char * | title, |
| const char * | body | ||
| ) |
Muted placeholder shown when a list has nothing to display.
| void UI::endCard | ( | ) |
Ends a card started with beginCard() or beginAutoHeightCard().
| ColumnMask UI::fitColumns | ( | std::span< const Column > | columns, |
| float | availableWidth, | ||
| float | stretchMinimum = 160.0f, |
||
| ColumnMask | hidden = 0 |
||
| ) |
Chooses the columns that fit the available width, dropping the highest priority numbers first (never horizontal scrolling).
| stretchMinimum | Unscaled minimum width left for stretch columns. |
| hidden | Columns the user hid (hiddenColumns()): never shown, however wide the table. Priority-0 columns ignore it and always stay. |
| void UI::formStrip | ( | std::span< const Outcome > | outcomes | ) |
Row of W/D/L markers (latest last).
| ColumnMask UI::hiddenColumns | ( | std::string_view | table, |
| std::span< const Column > | columns | ||
| ) |
Columns the user hid in a table, saved in the settings per table.
| table | Stable table key. |
| columns | The table's columns with their untranslated label keys (the keys identify the columns in the settings). |
| void UI::keyValue | ( | const char * | key, |
| const char * | value, | ||
| float | keyWidth | ||
| ) |
Muted key on the left, value on the right of the current row.
| bool UI::link | ( | const char * | label, |
| const char * | id | ||
| ) |
Selectable text that looks like a link; returns true on click.
| void UI::meter | ( | const char * | label, |
| float | fraction, | ||
| float | labelWidth, | ||
| const ImVec4 & | color, | ||
| const char * | valueText | ||
| ) |
Labelled bar with an explicit colour and value text (0-1).
| bool UI::moneyInput | ( | const char * | id, |
| int64_t & | value, | ||
| const MoneyInputOptions & | options = {} |
||
| ) |
Currency field showing the full amount; typing accepts plain numbers, either decimal mark and k/M/B (mila/mln/mld) units, with the reading or the reason for refusing it shown under the field. -/+ step 5% (Shift 10%, Ctrl 1%), chips set preset values.
| MoneyPreview UI::moneyPreview | ( | std::string_view | text, |
| const MoneyInputOptions & | options | ||
| ) |
What moneyInput() shows for the typed text.
| void UI::pageHeader | ( | const char * | title, |
| const char * | subtitle | ||
| ) |
Large page title with an optional muted subtitle.
| bool UI::parseMoney | ( | std::string_view | text, |
| int64_t & | value | ||
| ) |
Parses "14.4M", "1,5M", "850k", "€1,200,000", "€ 2,25 mln" (false when invalid or ambiguous; see NumberFormat::parseMoney()).
| bool UI::primaryButton | ( | const char * | label, |
| ImVec2 | size, | ||
| ButtonSize | buttonSize | ||
| ) |
Accent-filled call-to-action button.
| void UI::ratingChip | ( | double | rating | ) |
Rounded rating chip, coloured by the rating scale.
| bool UI::sameLineIfFits | ( | float | nextWidth, |
| float | spacing = -1.0f |
||
| ) |
SameLine() only when an item of the given width still fits.
| spacing | Gap before the item (negative = style item spacing). |
| bool UI::secondaryButton | ( | const char * | label, |
| ImVec2 | size, | ||
| ButtonSize | buttonSize | ||
| ) |
Neutral button for secondary actions.
| void UI::sectionLabel | ( | const char * | text | ) |
Small uppercase section label.
| bool UI::segmented | ( | const char * | id, |
| int & | selected, | ||
| std::span< const char *const > | labels, | ||
| float | width = 0.0f |
||
| ) |
Segmented control for small enumerations (joined buttons).
| selected | Index of the active segment, updated on click. |
| void UI::sparkline | ( | const char * | id, |
| std::span< const float > | values, | ||
| ImVec2 | size, | ||
| const ImVec4 & | color | ||
| ) |
Line chart of a series in a fixed box.
| void UI::staticHeadersRow | ( | ) |
Header row of a non-sortable table: plain labels without the hover highlight that suggests a clickable header.
| void UI::statTile | ( | const char * | id, |
| const char * | caption, | ||
| const char * | value, | ||
| const char * | footnote, | ||
| const ImVec4 & | valueColor, | ||
| float | width | ||
| ) |
Figure tile: caption, big value and an optional footnote.
| float UI::statTileHeight | ( | ) |
Height used by statTile(), for layout calculations.
| int64_t UI::stepMoney | ( | int64_t | value, |
| bool | up, | ||
| double | fraction | ||
| ) |
Next value of a money input's -/+ button: fraction up or down, rounded to three significant figures, and always at least 1 away.
| void UI::summaryRow | ( | const char * | label, |
| const char * | value, | ||
| const ImVec4 * | valueColor, | ||
| bool | emphasis | ||
| ) |
Label on the left, value right-aligned; emphasis draws a rule above and a larger value (totals).
| void UI::textFitted | ( | std::string_view | text, |
| float | maxWidth, | ||
| const ImVec4 & | color | ||
| ) |
Text item limited to maxWidth; shows the full text as a tooltip when it had to be shortened.
| void UI::textRight | ( | const char * | text | ) |
Text right-aligned in the current table cell or content region.
| void UI::textRightColored | ( | const ImVec4 & | color, |
| const char * | text | ||
| ) |
Coloured text right-aligned in the current cell.
| bool UI::toggleButton | ( | const char * | label, |
| bool | active, | ||
| ImVec2 | size, | ||
| ButtonSize | buttonSize | ||
| ) |
Filter/tab button: neutral when off, selection fill with an accent underline when on (one segment of UI::segmented()).