Leveraging The Text Resources Further

From SCI Wiki
Revision as of 19:34, 22 February 2016 by Andrew Branscom (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

You can move all your #title & #button text descriptions used in Print() statements:

In controls.sc, in the Print() procedure change the '(case #button' section:

Code:
			(case #button
		    	= hButtons[buttonCnt] (DButton:new())
		    	
				(if(>= Abs(params[+ paramCnt 1]) 0 and <= Abs(params[+ paramCnt 1]) 999)	
					(send hButtons[buttonCnt]:
						text(Format("%s" params[+ paramCnt 1] params[+ paramCnt 2]))
						value(params[+ paramCnt 3])
						setSize()
			    	)	
					= paramCnt + paramCnt 3
				)(else
					(send hButtons[buttonCnt]:
						text(params[++paramCnt])
						value(params[++paramCnt])
						setSize()
			    	)
				)		    	
		    	= btnsWidth (+ btnsWidth (+ (send hButtons[buttonCnt]:nsRight) 4))
		    	++buttonCnt
			)

And the '(case #title' section:

Code:
			(case #title
				++paramCnt

				(if(>= Abs(params[paramCnt]) 0 and <= Abs(params[paramCnt]) 999)
					Format("%s" params[paramCnt] params[+ paramCnt 1])
					++paramCnt
				)(else
					(send hDialog:text(params[paramCnt]))
			       )
			)

Now, you can use either technique - specify a static string or a text resource like this:

Code:
   Print("Hello there" #title 999 1)    //  999 is the text resource holding our title text
   Print("Hello there" #title "Greetings")   // the original way of specifying a title still works too

Same with buttons:

Code:
   Print("Make a selection" #button 888 2)   // 888 is the text resource holding our button text
   Print("Make a selection" #button "OK")    // the original way of specifying text for buttons still works

Of course, if you are this heap-bound, you'd have the actual text of your Print statement to be in a text resource too, so a more realistic example would be something like this:

Code:
  Print(0 15 #title 999 1)
  Print(0 22 #button 888 1)