Skip to content

Conversation

@dylanlee082
Copy link
Contributor

@dylanlee082 dylanlee082 commented Sep 1, 2025

Brief Description of What This PR Does

Convert all places of the hardcoded "lx" unit for light in the code to instead use a Unit set in a config file.

I also fixed a TODO in the code so the showEvenSmallValues setting works regardless of if a value has a unit or not. I don't think this actually impacts any compounds that currently have units since it's just temperature and now light, but it's there now for future use.

NOTE: This does not solve the full original problem of the tagged issue of unifying all compound unit logic. I didn't go through and attempt to do that full fix for a few reasons.

  1. While going through the code I didn't see any other obvious cases of this as most compounds don't use units and are just percentages.
  2. The way localization is setup for these cases made it difficult to read some of the code for how the units work. I think it would be beneficial to do a different PR for taking FormatSafe in StringUtils.cs a step further and creating a percentage format and unit format function in a helper class, so that working with this in the future is a little simpler.
  3. The CompountAmount.cs class seems to have most of the logic I would have wanted to consolidate, but it seems to be buildt specifically for the MicrobeEditor display, particularly the equations in the organelle descriptions. I didn't want to mess with this any more than I had to since I'm still learning my way around the project.

Related Issues

partially addresses #4895

Progress Checklist

Note: before starting this checklist the PR should be marked as non-draft.

  • PR author has checked that this PR works as intended and doesn't
    break existing features:
    https://wiki.revolutionarygamesstudio.com/wiki/Testing_Checklist
    (this is important as to not waste the time of Thrive team
    members reviewing this PR)
  • Initial code review passed (this and further items should not be checked by the PR author)
  • Functionality is confirmed working by another person (see above checklist link)
  • Final code review is passed and code conforms to the
    styleguide.

Before merging all CI jobs should finish on this PR without errors, if
there are automatically detected style issues they should be fixed by
the PR author. Merging must follow our
styleguide.

@hhyyrylainen hhyyrylainen added this to the Release 0.8.4 milestone Sep 2, 2025
@hhyyrylainen
Copy link
Member

I removed the mention of closing the issue that this only partially addresses.


sunlightChart.TooltipYAxisFormat = percentageFormat + " lx";
var sunlight = SimulationParameters.Instance.GetCompoundDefinition(Compound.Sunlight);
sunlightChart.TooltipYAxisFormat = percentageFormat + sunlight.Unit;
Copy link
Member

Choose a reason for hiding this comment

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

This is now missing a space between the % sign and the unit, I think.

Copy link
Member

@hhyyrylainen hhyyrylainen left a comment

Choose a reason for hiding this comment

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

I think it is good to clean up these explicit uses of "lx" but I think this PR needs a bit more further tweaking before merging.


numberPart = Localization.Translate("VALUE_WITH_UNIT")
.FormatSafe(Math.Round(amount, decimals), compoundDefinition.Unit);
numberPart = unitFormat.FormatSafe(percentageFormat
Copy link
Member

Choose a reason for hiding this comment

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

I think this should also have the "showEvenSmallValues" support and following the configured decimals value. Because right now if both ShowUnit and UsePercentageDisplay are defined, that stops many other features of this class from working, which seems very surprising from an API point of view to me.

@revolutionary-bot
Copy link

We are currently in feature freeze until the next release.
If your PR is not just a simple fix, then it may take until the release to get reviewed and merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

3 participants