• If you have a mod, tool or prefab, please use the Resources section. Click Mods at the top of the forums.

How can I get text="{playercoretemp}" to display 70°F instead of 70.00°F?

gaveitatry

New member
I am attempting to change the UI by editing the windows.xml.

{maptemperature} is great because it always displays the temperature without decimals, like 26°F.

{playercoretemp} always displays decimals no matter what, like 70.00°F. I don't even know why the decimals need to be displayed as the temperature always changes by whole numbers and not partial numbers.

This is a sample of the line of code that I have:
 

<label depth="7" name="LevelNumber" pos="4,-6" font_size="21" color="[white]" text="{playercoretemp}" height="34" justify="center" tooltip_key="xuiTemperature"/>




I would really like to be given a way to make the temperature display as a whole number.

 
Last edited by a moderator:
The display of the  'label'  element is being done by the main C# programming code. The xml can be considered as just a list of parameters to a C# (or whatever) function and in the code posted the temperature is an internal variable. One option might be to copy the playercoretemp into a var and manipulate it (e.g. cast it to an int) and then use that resultant int var in the xml statement.  I dont think you can do that in the xml. Am wondering if you might be able to do something like that with SCore.

A possible cheap/easier alternative is to use the width attribute in the statement with justify="left". Where width = (width of '00.00°F') - (width of '.00°F'). That should cut off the decimal places from the display.

edit: forgot to add that you can add the '°F' back afterwards using another label with text="°F"

cheers

 
Last edited by a moderator:
Thanks for the response, JoeSloeMoe. I actually ended up using that width method before you mentioned it. For some reason, the first time I tried it, the width method didn't work. But it could be because I just had faulty code. But later, as recommended, I added a overflow="ClampContent" which I was told is absolutely necessary in order for the width cutoff to work. This width method works, but it is not the ideal situation. I am not going to be too happy if the temperature drops to the single digits or goes over 100 degrees. And ideally, I wish I could just figure out a better mothod altogether. I don't know what SCore is, and I don't know this var int stuff, but maybe one day I will figure it out. For now, I decided to take a break from UI stuff and 7D2D. I got burned out on it working on it three days straight, the entire days. And I was continously restarting my game after every UI change, and my slow laptop made the game take longer than six minutes to restart each time. But finally someone told me about "xui reload" so I'll be using that in the future.

My new code is as follows. But it won't work if font-size is changed. If the font-size is changed, then the width needs to be changed as well.

 

<label depth="7" name="LevelNumber" pos="5,-6" font_size="21" color="[white]" text="{playercoretemp}" height="22" width="22" overflow="ClampContent" justify="right"/>
<label depth="7" name="LevelNumber" pos="19,-6" font_size="21" color="[white]" text="°F" height="22" width="22" overflow="ClampContent" justify="right"/>




I don't know how sloppy that is. Like I said, I got burned out at the end of the third day.

 
Without really looking into this as I'm not a modder (much), I'll just point out that single digit or triple digit the shouldn't matter if you get your total width from the temperature rather than using a static value.  For example, let's say that each character was a width of 1 for simplicity sake.  Your temp is 82.00°F.  That is a width of 7.  You subtract the width of .00°F (7 - 5) and are left with a width of 2.  If your temperature was 1.00°F, your final width would be 1.  And if it was 110.00°F, your final width would be 3.  In reach case, you would correctly cut off only the .00°F.

But that probably can't be done only with XML, so might not be much help.

 
Last edited by a moderator:
I got burned out on it working on it three days straight, the entire days. And I was continously restarting my game after every UI change, and my slow laptop made the game take longer than six minutes to restart each time. But finally someone told me about "xui reload" so I'll be using that in the future.
 


I feel that, the xml coding can burn a person out. I didnt know about 'xui reload' either so thanks for updating the thread, I kinda prefer a restart as it starts a new log file and thats much easier for debugging. If you dont already use the the code below you may find it useful in the future:

<!--log a msg to the log file-->
<triggered_effect trigger="onSelfBuffStart" action="LogMessage" message="some textmessage"/>
<!--log a variable to the log file-->
<triggered_effect trigger="onSelfBuffStart" action="CVarLogValue" cvar="someVariable"/>


Cheers

 
Yeah, this is a lousy hack that I am not too happy with.

I can't change the font to a monospace font like Consolas or Courier. If I use the font_face="" property, it makes the text invisible.

The styles xml files don't have any font definitions.

At font_size="21", the narrowest that I can make the label is width="18" before it cuts off numbers (example: 13 becomes 1 if I make it width="17").

So at font_size="21" and width="18", the temperature looks good when it is:
-1 or below (will look like: -2, -3, -4 instead of: -2.00, -3.00, -4.00)
10 or above (will look like: 11, 12, 13 instead of: 11.00, 12.00, 13.00)

But 0 through 9 looks bad. It will look like this:
0.
1.
2.
3.
4.
5.
6.
7.
8.
9.

And I tested this in a Snow Biome, I don't know how high the temperature can get the warmer biomes. If it gets above 99 degrees, then the width="18" will cut off the last number so 105 will look like 10.

 
Back
Top