Skip to content

[GEN][ZH] Implement System Time and Game Time display #1170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 13, 2025

Conversation

Mauller
Copy link

@Mauller Mauller commented Jun 22, 2025

Squash and merge

This PR implements the system clock and game time. They can be stylised and moved by adding the relevant fields to the inGameUi.ini file.

The system time is just currently offset from the left while the game time is positioned relative to the right side of the viewport.
This is to replicate how they are implemented within GenTool.

They are enabled by default for now to a font size of 8, but can also be disabled in the options.ini by setting their font size to 0.

The following will disable them independently if added to the options.ini.

SystemTimeFontSize = 0
GameTimeFontSize = 0

EDIT: Updated example with latest version
EDIT2: Updated once more with the now grey frame string
Example:
image

TODO

  • Test system time with -quickstart
  • Replicate in Generals
  • Update the Pull Request description

@Mauller Mauller self-assigned this Jun 23, 2025
@Mauller Mauller added Enhancement Is new feature or request Minor Severity: Minor < Major < Critical < Blocker Gen Relates to Generals ZH Relates to Zero Hour labels Jun 23, 2025
@xezon xezon added this to the Important features milestone Jun 23, 2025
@xezon
Copy link

xezon commented Jun 23, 2025

The placement of the right side timer is not optimal.

What are the options of fonts here?

GenTool uses the "Tahoma" font for its top screen texts, starting with a size of 8. I do wonder if it would make sense to use that font again, to present it with a familiar look for legacy players.

@Caball009
Copy link

@Mauller
Copy link
Author

Mauller commented Jun 24, 2025

The placement of the right side timer is not optimal.

What are the options of fonts here?

GenTool uses the "Tahoma" font for its top screen texts, starting with a size of 8. I do wonder if it would make sense to use that font again, to present it with a familiar look for legacy players.

Everything is based off position from the left side of the screen, i just replicated what the weapon timers were doing by using a percentage of screen * current horizontal resolution. At 4:3 the simulation timer is just shy of touching the right side of the screen edge.

I can make it relative to the right side of the screen HorizontalResolution - StartOfTextPosition, the annoying part is you can't easily determine the width of the string to adjust for different font sizes.

The font can be whatever we want it to be, i just chose Ariel as it matches the other fonts of the ui message text and weapon timers.

@Mauller
Copy link
Author

Mauller commented Jun 24, 2025

Ah it actually ends up being roughly 4 pixels per character as we have a fixed layout.

This gives an idea of what it should be if you input 00:00:00 it works out at 3.87 pixels per point size.
https://webutility.io/pixel-width-calculator

EDIT: Actually it's not that straightforward, it can vary and be over or under.
EDIT2: Might just have to use the fixed width size of characters based on the point size to give it a max width https://websemantics.uk/tools/font-size-conversion-pixel-point-em-rem-percent/

@xezon
Copy link

xezon commented Jun 24, 2025

In GenTool I have a function to get the extent for font + text to get its width and height. With this information, refined positioning is possible.

@Mauller
Copy link
Author

Mauller commented Jun 24, 2025

I could add the functionality to the display string class so it can return the area the current string covers.

@Mauller Mauller force-pushed the feature-systime-and-simtimer branch from aead4da to e471c53 Compare June 25, 2025 16:42
@Mauller
Copy link
Author

Mauller commented Jun 25, 2025

Just a rebase with recent main before making relevant changes.

@Mauller Mauller force-pushed the feature-systime-and-simtimer branch from e471c53 to 3b89ec9 Compare June 25, 2025 17:07
@Mauller
Copy link
Author

Mauller commented Jun 25, 2025

Updated with recent changes, the sim timer is anchored relative to the right of the screen, so adjusting the x coordinate will shift it left instead of right.

Also updated to use Tohama as the default font at 8 point.

image

@Mauller Mauller force-pushed the feature-systime-and-simtimer branch from 3b89ec9 to d45833d Compare June 25, 2025 18:02
@Mauller
Copy link
Author

Mauller commented Jun 25, 2025

Updated with Tahoma set to bold and rebased with last 5 pushes to main.

@Mauller Mauller force-pushed the feature-systime-and-simtimer branch from d45833d to 907d2e4 Compare June 26, 2025 17:14
@Mauller
Copy link
Author

Mauller commented Jun 26, 2025

Rebased with main and updated the colour of the frame string to be the same grey as Gentools

@Mauller Mauller force-pushed the feature-systime-and-simtimer branch from 907d2e4 to 7dfec20 Compare June 28, 2025 19:31
@Mauller
Copy link
Author

Mauller commented Jun 28, 2025

Made an update covering most points.

@Mauller Mauller force-pushed the feature-systime-and-simtimer branch from 7dfec20 to 44ee55a Compare June 29, 2025 09:48
@Mauller
Copy link
Author

Mauller commented Jun 29, 2025

Updated with recent suggestions

@Mauller Mauller force-pushed the feature-systime-and-simtimer branch from 44ee55a to 5be13ba Compare June 29, 2025 15:18
@Mauller
Copy link
Author

Mauller commented Jun 29, 2025

Reworked based on recent suggestions

@Mauller Mauller force-pushed the feature-systime-and-simtimer branch 2 times, most recently from 3c09aac to eff725d Compare July 4, 2025 20:00
@Mauller
Copy link
Author

Mauller commented Jul 4, 2025

Pushed with the postWindowDraw tweak added. should be good

Copy link

@xezon xezon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some more small things.

@Mauller Mauller force-pushed the feature-systime-and-simtimer branch from eff725d to 699612e Compare July 6, 2025 14:42
@Mauller
Copy link
Author

Mauller commented Jul 6, 2025

Had to add an extra check when drawing the game time as the quickstart menu is not considered ingame and is not considered the shellmap

@Mauller Mauller force-pushed the feature-systime-and-simtimer branch from 699612e to 2474fd6 Compare July 10, 2025 19:38
@Mauller
Copy link
Author

Mauller commented Jul 10, 2025

rebased with recent main

Copy link

@roossienb roossienb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good.

I've tested this on multiple resolutions in single player, skirmish and replays and all looks good.

@Mauller Mauller force-pushed the feature-systime-and-simtimer branch from 2474fd6 to b0510a5 Compare July 11, 2025 15:09
@Mauller
Copy link
Author

Mauller commented Jul 11, 2025

Code looks good.

I've tested this on multiple resolutions in single player, skirmish and replays and all looks good.

Just tweaked it to move out the font handling code and pushed those changes.

@Mauller Mauller force-pushed the feature-systime-and-simtimer branch from b0510a5 to 1d5d9d3 Compare July 12, 2025 14:44
@Mauller
Copy link
Author

Mauller commented Jul 12, 2025

Tweaked with recent suggestions.

@Mauller Mauller force-pushed the feature-systime-and-simtimer branch from 1d5d9d3 to 7668222 Compare July 12, 2025 15:36
@Mauller
Copy link
Author

Mauller commented Jul 12, 2025

Tweaked again

@xezon xezon changed the title [ZH] Implement the system time and simulation timer within InGameUI [ZH] Implement System Time and Game Time display Jul 12, 2025
Copy link

@xezon xezon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good. Ingame also looks good. Needs replicating in Generals. And description needs updating.

@Mauller Mauller force-pushed the feature-systime-and-simtimer branch from 7668222 to 641037c Compare July 12, 2025 16:29
@Mauller
Copy link
Author

Mauller commented Jul 12, 2025

Tweaked and pushed, will replicate to generals soon.

@Mauller Mauller changed the title [ZH] Implement System Time and Game Time display [GEN][ZH] Implement System Time and Game Time display Jul 13, 2025
@Mauller
Copy link
Author

Mauller commented Jul 13, 2025

Replicated to generals

@xezon xezon merged commit 27f7063 into TheSuperHackers:main Jul 13, 2025
20 checks passed
@xezon xezon deleted the feature-systime-and-simtimer branch July 13, 2025 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Is new feature or request Gen Relates to Generals Minor Severity: Minor < Major < Critical < Blocker ZH Relates to Zero Hour
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add game time display
5 participants