Browse Source
[ui, docs] add custom play time formatting
[ui, docs] add custom play time formatting
Signed-off-by: codeman4033 <codeman4033@eden-emu.dev>
No known key found for this signature in database
GPG Key ID: DE2F639DF2D265A3
13 changed files with 475 additions and 176 deletions
-
167docs/user/CustomPlayTime.md
-
3docs/user/README.md
-
17src/frontend_common/play_time_manager.cpp
-
7src/frontend_common/play_time_manager.h
-
4src/qt_common/config/shared_translation.cpp
-
2src/qt_common/config/uisettings.h
-
45src/yuzu/configuration/configure_ui.cpp
-
5src/yuzu/configuration/configure_ui.h
-
291src/yuzu/configuration/configure_ui.ui
-
8src/yuzu/game/game_list_p.h
-
7src/yuzu/set_play_time_dialog.cpp
-
88src/yuzu/util/util.cpp
-
7src/yuzu/util/util.h
@ -0,0 +1,167 @@ |
|||||
|
# Custom Play Time Syntax |
||||
|
|
||||
|
This document describes the formatting syntax used to display custom playtime values in the emulator. |
||||
|
|
||||
|
## Overview |
||||
|
|
||||
|
Playtime is internally stored as a total number of seconds. This formatting system allows users to control how that value is displayed by using tokens inside a format string. |
||||
|
|
||||
|
Example: |
||||
|
|
||||
|
``` |
||||
|
{H:02}:{M:02}:{S:02} |
||||
|
``` |
||||
|
|
||||
|
Output: |
||||
|
|
||||
|
``` |
||||
|
02:03:04 |
||||
|
``` |
||||
|
|
||||
|
## Tokens |
||||
|
|
||||
|
The following tokens can be used in format strings. |
||||
|
|
||||
|
| Token | Description | |
||||
|
| ----- | ------------------------ | |
||||
|
| `{d}` | Total days | |
||||
|
| `{h}` | Total hours | |
||||
|
| `{H}` | Hours component (0–23) | |
||||
|
| `{m}` | Total minutes | |
||||
|
| `{M}` | Minutes component (0–59) | |
||||
|
| `{s}` | Total seconds | |
||||
|
| `{S}` | Seconds component (0–59) | |
||||
|
|
||||
|
## Padding |
||||
|
|
||||
|
Tokens may optionally include zero-padding using the syntax `:NN`, where `NN` is the minimum width. |
||||
|
|
||||
|
Example: |
||||
|
|
||||
|
``` |
||||
|
{H:02}:{M:02}:{S:02} |
||||
|
``` |
||||
|
|
||||
|
This ensures each component is displayed with at least two digits. |
||||
|
|
||||
|
Example output: |
||||
|
|
||||
|
``` |
||||
|
02:03:04 |
||||
|
``` |
||||
|
|
||||
|
## Conditional Sections |
||||
|
|
||||
|
Conditional sections allow parts of the format string to appear only when a specific time unit is non-zero. This is useful for hiding units such as `0h`. |
||||
|
|
||||
|
Conditional sections use the following syntax: |
||||
|
|
||||
|
``` |
||||
|
[unit] ... [/unit] |
||||
|
``` |
||||
|
|
||||
|
Where `unit` is one of the following: |
||||
|
|
||||
|
| Unit | Condition | |
||||
|
| ---- | ------------------------------ | |
||||
|
| `d` | Display section if days > 0 | |
||||
|
| `h` | Display section if hours > 0 | |
||||
|
| `m` | Display section if minutes > 0 | |
||||
|
|
||||
|
Example: |
||||
|
|
||||
|
``` |
||||
|
[h]{H}h [/h][m]{M}m [/m]{S}s |
||||
|
``` |
||||
|
|
||||
|
Possible outputs: |
||||
|
|
||||
|
``` |
||||
|
1h 3m 4s |
||||
|
3m 4s |
||||
|
4s |
||||
|
``` |
||||
|
|
||||
|
Conditional sections may contain both tokens and literal text. |
||||
|
|
||||
|
## Escaping Braces |
||||
|
|
||||
|
To include literal braces in the output, they must be escaped using double braces. |
||||
|
|
||||
|
| Input | Output | |
||||
|
| ----- | ------ | |
||||
|
| `{{` | `{` | |
||||
|
| `}}` | `}` | |
||||
|
|
||||
|
Example: |
||||
|
|
||||
|
``` |
||||
|
Playtime: {{ {H}:{M}:{S} }} |
||||
|
``` |
||||
|
|
||||
|
Output: |
||||
|
|
||||
|
``` |
||||
|
Playtime: { 2:3:4 } |
||||
|
``` |
||||
|
|
||||
|
## Literal Text |
||||
|
|
||||
|
Any text outside of tokens or conditional sections is copied directly into the output. |
||||
|
|
||||
|
Example: |
||||
|
|
||||
|
``` |
||||
|
{h}h {M}m {S}s |
||||
|
``` |
||||
|
|
||||
|
Output: |
||||
|
|
||||
|
``` |
||||
|
26h 3m 4s |
||||
|
``` |
||||
|
|
||||
|
## Examples |
||||
|
|
||||
|
### Clock Format |
||||
|
|
||||
|
``` |
||||
|
{H:02}:{M:02}:{S:02} |
||||
|
``` |
||||
|
|
||||
|
Example output: |
||||
|
|
||||
|
``` |
||||
|
02:03:04 |
||||
|
``` |
||||
|
|
||||
|
### Human Readable Format |
||||
|
|
||||
|
``` |
||||
|
{h} hours, {M} minutes, {S} seconds |
||||
|
``` |
||||
|
|
||||
|
Example output: |
||||
|
|
||||
|
``` |
||||
|
26 hours, 3 minutes, 4 seconds |
||||
|
``` |
||||
|
|
||||
|
### Compact Format |
||||
|
|
||||
|
``` |
||||
|
[h]{H}h [/h][m]{M}m [/m][s]{S}s |
||||
|
``` |
||||
|
|
||||
|
Example output: |
||||
|
|
||||
|
``` |
||||
|
3m 4s |
||||
|
``` |
||||
|
|
||||
|
## Notes |
||||
|
|
||||
|
* Playtime values are derived from the total number of elapsed seconds. |
||||
|
* Component tokens (`H`, `M`, `S`) wrap within their normal ranges. |
||||
|
* Total tokens (`h`, `m`, `s`) represent the full accumulated value for that unit. |
||||
|
* This is based on the [fmt syntax](https://fmt.dev/12.0/syntax/). Almost everything there is also supported here. |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue