Jump to content
Sign in to follow this  
HazJ

Strngtable + structured text (HTML styling)

Recommended Posts

Hi all,

Styling doesn't seem to show for some reason. The text still displays though?

player createDiarySubject [localize "STR_briefing_subjectWasteland", localize "STR_briefing_subjectWasteland"];
player createDiaryRecord [localize "STR_briefing_subjectWasteland", [localize "STR_briefing_recordAbout", localize "STR_briefing_sectionAbout"]];
<English>&lt;t size='5' align='center' font='RobotoCondensedBold' color='#ffffff'&gt;Wasteland&lt;/t&gt;</English>

Outputs:

Wasteland

(no styling)

This however works fine:

hintSilent parseText localize "STR_briefing_sectionAbout";

Styling is shown.

Share this post


Link to post
Share on other sites

Here is a example of what I use

https://github.com/michail-nikolaev/task-force-arma-3-radio/blob/1.0/addons/core/functions/diary.sqf#L6

https://github.com/michail-nikolaev/task-force-arma-3-radio/blob/1.0/addons/core/stringtable.xml#L1950

 

Seems like I'm doing exactly the same as you. I don't know if mine displays correctly ingame. I never looked at it :D

Share this post


Link to post
Share on other sites
15 hours ago, HazJ said:

Hi all,

Styling doesn't seem to show for some reason. The text still displays though?


player createDiarySubject [localize "STR_briefing_subjectWasteland", localize "STR_briefing_subjectWasteland"];
player createDiaryRecord [localize "STR_briefing_subjectWasteland", [localize "STR_briefing_recordAbout", localize "STR_briefing_sectionAbout"]];

<English>&lt;t size='5' align='center' font='RobotoCondensedBold' color='#ffffff'&gt;Wasteland&lt;/t&gt;</English>

 

 

I think it's done a little differently in the diary, check this out https://community.bistudio.com/wiki/createDiaryRecord

 

So it would look more like <font size='5' face='RobotoCondensedBold' color='#ffffff'>

I didn't know it was possible to put structured text in there, now I want to try it out. Alas, 9 more hours to wait.

 

Share this post


Link to post
Share on other sites
1 hour ago, HazJ said:

@AZCoder- You can't use that in stringtable, you have to use HTML character entities, see below:

https://www.w3schools.com/html/html_entities.asp

@Dedmen - Hmm, really odd. It displays the text, just without styling. ArmA'd again? :down:

 

 

I'm a web developer, I know. My intent was to make it clear to you what was wrong with your structure. Font is the tag name you need to use. I'm going to test it myself a bit later today when I can.

I suggest testing it without the stringtable, and when it works, just convert it into htmlentities and it should be good.

Share this post


Link to post
Share on other sites

https://community.bistudio.com/wiki/parseText

See examples at bottom. I don't think it matters on the order. As I said, it works when I do:

hintSilent parseText localize "STR_briefing_sectionAbout";

The styling just doesn't show in the briefing part, only standard default styling. Unless I have misunderstood you?

Share this post


Link to post
Share on other sites

@HazJ I have Arma up now so I can give a more concrete example. What I was referring to earlier was on the createDiaryRecord page, it tells you what tags are supported. Forget about parseText, this is one of those exceptions to the rules.

 

For a non-xml way, you could have


createDiaryRecord ["Diary", ["Info", "<font size='15' face='RobotoCondensedBold' color='#AA0033'>Blow up something!</font>"]];

 

You put your text inside a <font> tag. Notice the size is in pixels now, so you need bigger values here than with structured text.

 

Inside an xml and converted to htmlentities


            <Key ID="STR_DIARY_INFO2">
                <English>
                    &lt;font size='15' face='RobotoCondensedBold' color='#337799'&gt;Recon the safehouse.&lt;/font&gt;
                </English>
            </Key>

which of course would be called like this:  player createDiaryRecord ["Diary", ["Info2", localize "STR_DIARY_INFO2"]];

Both have been tested and verified :supercool:

 

  • Like 1

Share this post


Link to post
Share on other sites

@AZCoder

Ah. I see. Thank you! I should of read the createDiaryRecord Wiki properly as it states right there, lol. I have never really used briefing with structured text + stringtable, only other things which is why I was so confused as to why hintSilent parseText worked. It is also odd that it shown the text without styling but still understood and managed to strip unsupported tags (font) there. Thanks again anyway! :)

  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, AZCoder said:

Inside an xml and converted to htmlentities

 

Might just be me, but I don't think you really should put style into a stringtable. Just pure strings.

Then apply the styling (an extra call to format, or simple string concatenation/appending) just before you call createDiaryRecord (or whatever).

 

 

Share this post


Link to post
Share on other sites
5 minutes ago, HazJ said:

unless you know a reason why not to?

 

Sure. For one duplication: if you actually go on and do translate your strings to multiple languages, you're going to duplicate all your styling, which is a mess to manage. And for two, flexibility: you might wanna use the very same string in a different context, maybe with, maybe without, or different styling alltogether.

In the end, styling can be considered "code" and doesn't need to be translated. It's not "language" (or "data").

  • Like 1

Share this post


Link to post
Share on other sites

@rübe - Yeah, that is actually true. Two very good reasons. Think I am going to get rid of it now ha, after I just got it working. (:

Share this post


Link to post
Share on other sites
43 minutes ago, rübe said:

 

Might just be me, but I don't think you really should put style into a stringtable. Just pure strings.

Then apply the styling (an extra call to format, or simple string concatenation/appending) just before you call createDiaryRecord (or whatever).

 

 

 

Normally I would agree with that, but I don't think there's another option in Arma to display style within diary/journal entries. That's why they provided a way of doing so. I know it's kind of like doing in-line styles in HTML before CSS got popular, something considered bad today. Unfortunately Arma is not a consistent animal. Yes it smells bad, but hey, it's Arma! :whip:   Also, mission making isn't exactly Enterprise level software. It's a fine goal to strive for, but ultimately you have to do what works within the limits of the game engine. So if you want a fancy font style or whatever for a particular journal entry, then do it! Odds are it won't hurt anything, nobody is going to care one way or another. And again I respect your opinion on it because I would agree with it in most any other circumstance.

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
Just now, AZCoder said:

there's [no other] option in Arma to display style within diary/journal entries

 

oh... of course, it's Arma afterall. :sigh:

 

Just now, AZCoder said:

It's a fine goal to strive for, but ultimately you have to do what works within the limits of the game engine.

 

You do what you gotta do... 

sure, sure. :shrug:

  • Like 2

Share this post


Link to post
Share on other sites

ArmA :hang:

  • Haha 3

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×