Daemon icon indicating copy to clipboard operation
Daemon copied to clipboard

renderer: revamp image and shader listing

Open illwieckz opened this issue 1 year ago • 5 comments

Deep revamp of image and shader listing functions.

  • Make it always use Log::CommandInteractionMessage to avoid being truncated by logs.suppression.enabled.
  • More std::string, less char* and related C functions.
  • More map-based decision (more generic code, and move copy-pasting risks to data instead of logic).
  • Added strings for all image formats that I managed to list but were not known before.

A rewrite of the shader listing was already done by me some time ago, the rewrite of the image listing was now done in a similar way but even pushed forward, and the shader listing was then pushed to that same level.

illwieckz avatar Feb 19 '24 17:02 illwieckz

As it was already done for shader listing, column sizing is now automatic (no need for hardcoding padding space in endless switch case blocks).

illwieckz avatar Feb 19 '24 17:02 illwieckz

The better way to avoid log suppression would be to use a Cmd::StaticCmd and its Print member function.

slipher avatar Feb 19 '24 22:02 slipher

The better way to avoid log suppression would be to use a Cmd::StaticCmd and its Print member function.

To me the code looks good enough with Log::CommandInteractionMessage to be merged and is already better than current code.

I will postpone or even leave to someone else the task to port those commands to the Cmd::StaticCmd class, this can be done later as a next step.

illwieckz avatar Feb 20 '24 15:02 illwieckz

I will postpone or even leave to someone else the task to port those commands to the Cmd::StaticCmd class, this can be done later as a next step.

Well, using CommandInteractionMessage is something of a step backwards wrt migrating to StaticCmd because for every formatted log you had to pull it out into a Str::Format, whereas with the command you can do a simple replacement of the log function with Print.

slipher avatar Feb 22 '24 03:02 slipher

The whole PR is still a step forward because:

  • all the Com_sprintf( buffer, sizeof( buffer ), … are gone,
  • there is no hardcoded space padding anymore,
  • the padding is now computed from inputs to always be fine,
  • the output is not truncated by logs.suppression.enabled,
  • some enums are now properly printed,
  • etc.

I even consider that migrating to std::string even when using CommandInteractionMessage is still a step forward compared to the char buffer[ MAX_TOKEN_CHARS ] stuff.

illwieckz avatar Feb 22 '24 21:02 illwieckz

It now looks ready to me.

illwieckz avatar Mar 10 '24 15:03 illwieckz