Author Topic: UILabel and restricted strings...  (Read 11897 times)

Joe @ ByDesign Games

  • Guest
UILabel and restricted strings...
« on: May 09, 2012, 07:36:10 PM »
UI dev here noticed UILabel goes blank whenever "[ Body ]" is used for .text, yet we've legitimate need to display such string.

Is there a way to display such string without UILabel going blank?

Also, is the list of restricted strings documented somewhere? Took 30min to track this down, ugh.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel and restricted strings...
« Reply #1 on: May 09, 2012, 07:59:29 PM »
Turn off encoding on the label. 6 characters encased within square brackets is a special symbol.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel and restricted strings...
« Reply #2 on: May 09, 2012, 08:00:31 PM »
Btw, if you're not using symbols (color encoding essentially), turn off encoding on those labels. Turning off that, and multi-line, will actually make your labels faster.

Joe @ ByDesign Games

  • Guest
Re: UILabel and restricted strings...
« Reply #3 on: May 09, 2012, 08:03:09 PM »
6 characters eh? Ahh that explains why [Body] works, but [ Body ] does not.

Turns out we don't need encoding for this UILabel, so the fix is in; though seems sort of an arbitrary restriction...

just saying! :)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel and restricted strings...
« Reply #4 on: May 09, 2012, 08:06:18 PM »
It's just how you encode colors.

[RrGgBb]

Joe @ ByDesign Games

  • Guest
Re: UILabel and restricted strings...
« Reply #5 on: May 09, 2012, 08:08:06 PM »
hmm any reason # isn't used? as in [#RrGgBb]

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel and restricted strings...
« Reply #6 on: May 09, 2012, 08:08:41 PM »
Less characters. :P

Joe @ ByDesign Games

  • Guest
Re: UILabel and restricted strings...
« Reply #7 on: May 09, 2012, 08:09:12 PM »
:P

Joe @ ByDesign Games

  • Guest
Re: UILabel and restricted strings...
« Reply #8 on: May 10, 2012, 11:27:43 AM »
My thinking is:

"forcing users to never have 6 characters within brackets"

is more annoying / unnatural / bizarre than:

"forcing use of commonly accepted # character to specify colors within brackets"

Adding, the longer removing the 6 char limit and instead requiring # for color is put off, the harder it will be to fix later.

ryan

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 90
    • View Profile
Re: UILabel and restricted strings...
« Reply #9 on: May 10, 2012, 01:20:31 PM »
Or if nothing else, provide some way to encode a left square bracket and a function to do just that on a given string.  I've had one or two cases where I wanted to embed some colors in a label, but also include text input by a user without allowing that portion of the text to change colors.  I put off actually dealing with it, but it would be convenient if NGUI supported that.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel and restricted strings...
« Reply #10 on: May 10, 2012, 02:36:43 PM »
Simple enough to do. Strip the symbols from the user-input text before merging it with your own symbol-supporting text.

NGUITools.StripSymbols

ryan

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 90
    • View Profile
Re: UILabel and restricted strings...
« Reply #11 on: May 11, 2012, 01:24:03 PM »
I noticed StripSymbols, but then I'm not displaying the text entered by the user, am I.  :P  I would want to preserve the brackets and any other random junk entered by the user.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: UILabel and restricted strings...
« Reply #12 on: May 11, 2012, 04:11:12 PM »
Then you don't allow encoding there. :D