We have detected that cookies are not enabled on your browser. Please enable cookies to ensure the proper experience.
Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2013
    Posts
    42

    colored text (Garan! Help! lol)

    Okay, I'm calling uncle.

    I'm trying to display colored text in a LOTRO window. I've got the strings formatted in the way that works in the in-game chat window. But when I put those strings into a label ( :AppendText ) the <> commands aren't treated as distinguished.

    The API documentation is (as so often the case) no help whatsoever, as it gives no details about what the format of the string passed to AppendText() should be.

    I know it's *possible* to do this -- since Garan's Rainbow has a text field ("Preview") with multiple colors in it. But if I've puzzled my way through that code correctly, each clip of text with a different color is a new Label structure.

    Does this mean there's no built-in way to have text of varying color within the same single structure... or is that just a Label restriction? Because a sizeable block of text, in different colors, where each discrete block has to be its own Label structure... that's a HUGE overhead in unnecessary memory and processing just to get variably colored text!

    ARGH.

    Please, Garan, say it ain't so!!!


    Is there any way to hook into the routines that drive the in-game chat interface... the ones which happily process the <rgb> and <select> and similar code?...

    Or *something* to reduce the requisite overhead to something reasonable?

    I just need a static, multi-colored text display...

  2. #2
    Join Date
    Mar 2007
    Posts
    1,590
    Quote Originally Posted by Eddenwulf View Post
    Please, Garan, say it ain't so!!!
    It ain't so.

    Oh, you wanted more than just that?

    On a more serious note, Rainbow Chat predates the ability to use color formatting tags in a Lua control, thus the preview used separate controls with a distinct forecolor for each piece of text. I probably should rewrite the preview to make use of the formatting tags, but, as they say, if it ain't broke, don't fix it.

    As to your question about colored text, I will add an example of how it works when I get a chance later tonight (I don't like to provide answers/examples without actually running them in-game).

    First, did you remember to use :SetMarkupEnabled(true) on the label? That is one easy thing to overlook.

    EDIT: Ok here's a simple sample with a Label, TextBox and Lotro.TextBox showing colored text in all three.
    Code:
    testWindow=Turbine.UI.Lotro.Window()
    testWindow:SetSize(400,140)
    testWindow:SetPosition(200,200)
    testWindow:SetText("Color Test Window")
    testWindow:SetVisible(true)
    
    testLabel=Turbine.UI.Label()
    testLabel:SetParent(testWindow)
    testLabel:SetSize(380,20)
    testLabel:SetPosition(10,45)
    testLabel:SetMarkupEnabled(true)
    testLabel:SetText("<rgb=0xFF0000>this</rgb> <rgb=0x00FF00>is</rgb> <rgb=0xFFFF00>a</rgb> <rgb=0x0000FF>test</rgb>")
    
    testText1=Turbine.UI.TextBox()
    testText1:SetParent(testWindow)
    testText1:SetSize(380,20)
    testText1:SetPosition(10,70)
    testText1:SetMarkupEnabled(true)
    testText1:SetText("<rgb=0xFF0000>this</rgb> <rgb=0x00FF00>is</rgb> <rgb=0xFFFF00>another</rgb> <rgb=0x0000FF>test</rgb>")
    
    testText2=Turbine.UI.Lotro.TextBox()
    testText2:SetParent(testWindow)
    testText2:SetSize(380,20)
    testText2:SetPosition(10,95)
    testText2:SetMarkupEnabled(true)
    testText2:SetFont(Turbine.UI.Lotro.Font.Verdana18)
    testText2:SetText("<rgb=0xFF0000>this</rgb> <rgb=0x00FF00>is</rgb> <rgb=0xFFFF00>the</rgb> <rgb=0x00ffff>third</rgb> <rgb=0x0000FF>test</rgb>")
    Last edited by Garan; Mar 25 2014 at 04:23 PM.

  3. #3
    Join Date
    Apr 2013
    Posts
    42

    Phew! Thanks!

    Phew. A relief.

    My heart sank when - after my initial straightforward attempt didn't work - I stepped through the Rainbow code to see how you'd done it, only to discover all those separate Label objects!

    Your reply pointed me toward the SetMarkupEnabled() command, and my straightforward initial test now works.

    *** phew ***

    thanks!!


    (For future googlers who land here: use the control's SetMarkupEnabled(true) command to get the interface to parse the <rgb> and suchlike as special commands, rather than just more ordinary text!)

  4. #4
    Join Date
    Aug 2015
    Posts
    120
    Quote Originally Posted by Eddenwulf View Post


    (For future googlers who land here: use the control's SetMarkupEnabled(true) command to get the interface to parse the <rgb> and suchlike as special commands, rather than just more ordinary text!)
    Future googler here, many years later

    Is there any doccumentation about other special commands that you can use, for example one to change font size?

    Thanks

  5. #5
    Join Date
    Mar 2007
    Posts
    1,590
    Quote Originally Posted by Agollas View Post
    Future googler here, many years later

    Is there any doccumentation about other special commands that you can use, for example one to change font size?

    Thanks
    Lotro uses two bitmaps to produce fonts on controls (one for the text and one for the outline) so the font face and size are both determined by the font ID passed in the SetFont method of a text or label control. The API now contains all of the possible font and size values in the Turbine.UI.Lotro.Font enumeration. The MoorMap plugin contains the latest version of my FontSupport.lua file that supports displaying a user selection list for fonts as well as font metrics (to determine the height and width of a particular string in a particular font, quite handy for internationalization, etc. where you don't know the string or the font face/size at design time). Unfortunately, MoorMap doesn't really make good use of FontSupport.lua (it's only used for the metrics in popup dialogs) but the Anthology plugin makes extensive use of FontSupport (the version published with Anthology is out of date, so replace it with the version from MoorMap to see all of the proper fonts). Feel free to dig into them to see how FontSupport works and to use FontSupport.lua in your own projects - I just ask that if you include FontSupport.lua (or any other .lua file) in a plugin that you give appropriate credit.

    https://www.lotrointerface.com/downl...2-MoorMap.html
    https://www.lotrointerface.com/downl...Anthology.html
    Last edited by Garan; Jul 24 2019 at 02:39 PM. Reason: typo

  6. #6
    Join Date
    Aug 2015
    Posts
    120
    Quote Originally Posted by Garan View Post
    Lotro uses two bitmaps to produce fonts on controls (one for the text and one for the outline) so the font face and size are both determined by the font ID passed in the SetFont method of a text or label control. The API now contains all of the possible font and size values in the Turbine.UI.Lotro.Font enumeration. The MoorMap plugin contains the latest version of my FontSupport.lua file that supports displaying a user selection list for fonts as well as font metrics (to determine the height and width of a particular string in a particular font, quite handy for internationalization, etc. where you don't know the string or the font face/size at design time). Unfortunately, MoorMap doesn't really make good use of FontSupport.lua (it's only used for the metrics in popup dialogs) but the Anthology plugin makes extensive use of FontSupport (the version published with Anthology is out of data, so replace it with the version from MoorMap to see all of the proper fonts). Feel free to dig into them to see how FontSupport works and use FontSupport.lua in your own projects - I just ask that if you include FontSupport.lua (or any other .lua file) in a plugin that you give appropriate credit.

    https://www.lotrointerface.com/downl...2-MoorMap.html
    https://www.lotrointerface.com/downl...Anthology.html
    Thanks for the reply, I managed to do what I was wanting to with :SetFont(....) in the end, didn't realise that it could also affect the size.

    Will definitely look in to your FontSupport.lua though

    Have added credit to my plugin anyway, for all the other information/code that you have provided over the years

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

This form's session has expired. You need to reload the page.

Reload