Graphics

 View Only
  • 1.  Changing font material based upon information in a text field

    Posted 11-03-2014 15:17

    Hello!

    I'm trying to create a page that changes the colour of two text fields based upon the information of one. I've tried two different ways of approaching this - change the material and change the font with a material on the font. Both ways will work locally but neither seem to update through an iNews MOS controller. It will update the information but not the colour. There are five sets of pairs on the page to do the same thing so it also loops. I have tried to do just one set to start but it makes all of the same results - works locally, doesn't work in iNews MOS.

    When I bring it into the remote sequencer, it displays the same as iNews. I bring it locally and it works.

    One more piece to the puzzle is the text that I would like to compare is a font I created with pictures so I need to copy the text to a hidden field to use as the comparison.

    This script is on OnOnline and OnPreviewRender.

    Does anyone have any suggestions? Thank you!!!



    dim card(5) as xptextobject

    dim num(5) as xptextobject

    dim suit(5) as xptextobject

    dim material(5) as xpMaterial

    dim i as integer

    for i = 1 to 5

    self.getobjectbyname("Card" & i, card(i))

    self.getobjectbyname("Number" & i, num(i))

    self.getobjectbyname("Suit" & i, suit(i))

    'dim suits as string = card(i).text

    dim suits as string

    suits = card(i).text

    suit(i).text = suits

    'copying the information of the custom font to a font object to see & compare the letter

    dim TheSuit as string

    TheSuit = suits

    'copying the letter to compare

    dim temp as string

    'This is the placeholder to hold the information of the text field while the material is changed

    Select Case TheSuit

    'looking at the letter to determine what font to use - red or black

    Case "h", "d", "H", "D"

    'changing the material to PokerRed if the letter matches above

    temp = num(i).text

    'Get the current information of the number

    Engine.GetMaterialByName("PokerRed", material(i))

    'Get the red material

    num(i).text = ""

    'Remove the text

    num(i).SetMaterial(0, material(i))

    'Set the material

    num(i).text = temp

    'Putting the information back into the text field

    Case "c", "s", "C", "S"

    temp = num(i).text

    'Get the current information of the number

    'changing the material to PokerBlack if the letter matches above

    Engine.GetMaterialByName("PokerBlack", material(i))

    'Get the black material

    num(i).text = ""

    'Remove the text

    num(i).SetMaterial(0, material(i))

    'Set the material

    num(i).text = temp

    'Putting the information back into the text field

    End Select

    Select Case TheSuit

    'looking at the letter to determine what font to use - red or black

    Case "h", "d", "H", "D"

    'changing the material to PokerRed if the letter matches above

    temp = card(i).text

    'Get the current information of the number

    Engine.GetMaterialByName("PokerRed", material(i))

    'Get the red material

    card(i).text = ""

    'Remove the text

    card(i).SetMaterial(0, material(i))

    'Set the material

    card(i).text = temp

    'Putting the information back into the text field

    Case "c", "s", "C", "S"

    temp = card(i).text

    'Get the current information of the number

    'changing the material to PokerBlack if the letter matches above

    Engine.GetMaterialByName("PokerBlack", material(i))

    'Get the black material

    card(i).text = ""

    'Remove the text

    card(i).SetMaterial(0, material(i))

    'Set the material

    card(i).text = temp

    'Putting the information back into the text field

    End Select

    Next i


  • 2.  RE: Changing font material based upon information in a text field

    Posted 11-04-2014 16:37
    We do something similar for elections, but it should apply to cards just the same. In essence, you need to have the text object you're going to display, and a string within your script to "hold" the text while you change the font. Once the text is input, it also sets the font, and you need to remove the text in order to change it. Here's a similar script we use:

    dim name as xpTextObject

    dim party as xpTextObject

    dim temp as strong = nothing

    dim red as xpFont

    dim blue as xpFont

    dim white as xpFont

    'get the text objects

    Self.GetObjectByName("Candidate Name", name)

    Self.GetObejctByName("Candidate Party", party)

    'get the fonts

    Engine.GetFontByName("Red Font", red)

    Engine.GetFontByName("Blue Font", blue)

    Engine.GetFontByName("White Font", white)

    'this is where the fonts actually get changed

    if ucase(party.Text) = "R" then 'if the party text says "R"

    temp=name.Text 'copy the text from the name object to the placeholder string

    name.Text="" 'remove the text from the name object

    name.CurrentFont=red 'change the font

    name.Text=temp 'copy the text from the placeholder string back into the name text object

    elseif ucase(party.Text) = "D" then 'check for other possibilies

    temp=name.Text

    name.Text=""

    name.CurrentFont=blue

    name.Text=temp

    else

    temp=name.Text

    name.Text=""

    name.CurrentFont=white

    name.Text=temp

    end if


    You could do something like:

    dim card as xpTextObject

    dim num as xpTextObject

    dim suit as xpTextObject

    dim material as xpMaterial

    dim i as Integer

    dim temp as string = nothing

    dim red as xpMaterial

    dim black as xpMaterial

    'get your materials

    Engine.GetMaterialByName("PokerRed", red)

    Engine.GetMaterialByName("PokerBlack", black)

    'start the loop

    for i = 1 to 5

    Self.GetObjectByName("Card" & i, card)

    Self.GetObjectByName("Number" & i, num)

    Self.GetObjectByName("Suit" & i, suit)

    'if any of the text in the card text object is "h", "H", "d", or "D" then change the num material to red

    'elseif any of the text in the card text object is "c", "C", "s", or "S" then change the num material to black

    if InStr(ucase(card.Text), "H") > 0 or InStr(ucase(card.Text), "D") > 0 then

    temp=num.Text

    num.Text=""

    num.SetMaterial(0, red)

    num.Text=temp

    elseif InStr(ucase(card.Text), "C") > 0 or InStr(ucase(card.Text), "S") > 0 then

    temp=num.Text)

    num.Text=""

    num.SetMaterial(0, black)

    num.Text=temp

    enf if

    next i


    #XPression


  • 3.  RE: Changing font material based upon information in a text field

    Posted 11-04-2014 21:12
    Thank you! I will try this out!

    #XPression