Skip to content
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

Add a new widget to display weight with the format "##.#/##.#[unit]" #77212

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

AudBobb
Copy link
Contributor

@AudBobb AudBobb commented Oct 21, 2024

Summary

Features "Add a new widget to display weight as "##.#/##.#[unit]""

Purpose of change

I felt like this was a glaring hole in the information you could display in the sidebar, considering all the random stuff you can display over there, so I fixed it.

Describe the solution

Added a new functions in display,cpp to pull current units and concat current weight with max weight, and calculate what percent of the max they are to color them appropriately, then added the requisite code to widget.cpp to call on this information.

I then added a new widgets to legacy labels sidebar to display this new information, because that's the sidebar I use. If anyone wants it added to another sidebar, speak up.

Describe alternatives you've considered

Not doing the imperial version because pounds make no sense

Testing

image
image

Additional context

I'd like to thank my gf for being patient with me while I ignored the show we were watching all day today, and I'd like to thank chatGPT for holding my hand and helping me setup the compiler in visual code, and helping me with c++ syntax because my coding experience is limited to java from 15 years ago, and lua from writing software in the minecraft computercraft mod

My head hurts

I'd also like to thank @Zenefess for giving me some guidance on how widgets work when I first thought about doing this a month or two ago

Should probably rename the existing carry_weight_text variables to denote that they handle the carry weight as a percent, because it's somewhat ambiguous

…and "##.#/##.# lb", and add the widgets to the legacy labels sidebar
@github-actions github-actions bot added Info / User Interface Game - player communication, menus, etc. [JSON] Changes (can be) made in JSON [C++] Changes (can be) made in C++. Previously named `Code` <Enhancement / Feature> New features, or enhancements on existing labels Oct 21, 2024
Copy link
Contributor

Spell checker encountered unrecognized words in the in-game text added in this pull request. See below for details.

Click to expand
  • Weight Carried (lb)

This alert is automatically generated. You can simply disregard if this is inaccurate, or (optionally) you can also add the new words to tools/spell_checker/dictionary.txt so they will not trigger an alert next time.

Hints for adding a new word to the dictionary
  • If the word is normally in all lowercase, such as the noun word or the verb does, add it in its lower-case form; if the word is a proper noun, such as the surname George, add it in its initial-caps form; if the word is an acronym or has special letter case, such as the acronym CDDA or the unit mW, add it by preserving the case of all the letters. A word in the dictionary will also match its initial-caps form (if the word is in all lowercase) and all-uppercase form, so a word should be added to the dictionary in its normal letter case even if used in a different letter case in a sentence.
  • For a word to be added to the dictionary, it should either be a real, properly-spelled modern American English word, a foreign loan word (including romanized foreign names), or a foreign or made-up word that is used consistently and commonly enough in the game. Intentional misspelling (including eye dialect) of a word should not be added unless it has become a common terminology in the game, because while someone may have a legitimate use for it, another person may spell it that way accidentally.

I don't format goodly

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@github-actions github-actions bot added astyled astyled PR, label is assigned by github actions json-styled JSON lint passed, label assigned by github actions labels Oct 21, 2024
@IdleSol
Copy link
Contributor

IdleSol commented Oct 21, 2024

Is there any reason to have separate widgets for kg and lbs?

In the settings: USE_METRIC_WEIGHTS contains the value kg or lbs. We read the variable and use whichever option is specified in it.

@AudBobb
Copy link
Contributor Author

AudBobb commented Oct 21, 2024

I could probably check that in the display function, I'll look into it when I get home tonight

I honestly threw the imperial one in as a complete after thought

@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Oct 21, 2024
@AudBobb AudBobb changed the title Add two new widgets to display weight with the format "##.#/##.# kg" … Add a new widgets to display weight with the format "##.#/##.#[unit]" … Oct 21, 2024
@AudBobb
Copy link
Contributor Author

AudBobb commented Oct 21, 2024

made necessary changes to remove the code dedicated to the imperial version, and modified the metric function so it detects the users mass unit and adjusts accordingly. Also renamed all variable names to be non unit specific

AudBobb and others added 2 commits October 21, 2024 15:37
… to read users mass setting and adjust the display accordingly
Formatting

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@AudBobb AudBobb changed the title Add a new widgets to display weight with the format "##.#/##.#[unit]" … Add a new widget to display weight with the format "##.#/##.#[unit]" … Oct 21, 2024
@AudBobb AudBobb changed the title Add a new widget to display weight with the format "##.#/##.#[unit]" … Add a new widget to display weight with the format "##.#/##.#[unit]" Oct 21, 2024
@IdleSol
Copy link
Contributor

IdleSol commented Oct 21, 2024

        unit = "lb";

lbs?

UPD. And it wouldn't hurt to add a space between the value and kg/lb.

@github-actions github-actions bot added astyled astyled PR, label is assigned by github actions and removed astyled astyled PR, label is assigned by github actions labels Oct 21, 2024
@AudBobb
Copy link
Contributor Author

AudBobb commented Oct 21, 2024

image
image
Updated

@IdleSol
Copy link
Contributor

IdleSol commented Oct 21, 2024

Okay, I'm not good with the imperial system of measurement. Wiki says it's lb. But in the options, it's lbs. It's better to check with people who use it.

And it's definitely not correct to use kgs for metric.

@AudBobb
Copy link
Contributor Author

AudBobb commented Oct 21, 2024

xD Iooks like lbs is correct for imperial. You'd think as an american I'd know this, but shit makes no gd sense
image

@github-actions github-actions bot removed the BasicBuildPassed This PR builds correctly, label assigned by github actions label Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions [C++] Changes (can be) made in C++. Previously named `Code` <Enhancement / Feature> New features, or enhancements on existing Info / User Interface Game - player communication, menus, etc. [JSON] Changes (can be) made in JSON json-styled JSON lint passed, label assigned by github actions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants