[THUG2][PC] Changing your default text colour.

Tutorial forum for Tony Hawk games.
Forum rules
No requests, use other sections for that. TAG your titles [THAW][THUG2] etc.
Anteara
Posts: 268
Joined: Thu Oct 14, 2010 2:55 am
Contact:

[THUG2][PC] Changing your default text colour.

Postby Anteara » Fri Jan 28, 2011 5:21 pm

In this tutorial I will show you how to change your default text colour.
Things needed:
  • QB Decompiler/Compiler
  • Knowledge with %GLOBAL%

IMPORTANT: If you have NO IDEA what GLOBAL does, read this first, it's a great tutorial that explains what it does in detail http://home.arcor.de/hackthps/GLOBAL/howtouseglobal.html

The way this tutorial works:
  • The functions will be displayed in quotes (because I can't use color in code)
  • Parts of each function will be color coded, underneath the function will show you what each color means

The reason I am color coding things is so people will learn what each part of the function does.


How to change your default text colour

1) Navigate to game.qb and decompile it

2) Find this function

Code: Select all

:i function $entered_chat_message$
   :i call $GetTextElementString$ arguments
      $id$ = $keyboard_current_string$
   :i call $SendChatMessage$ arguments
      $string$ = %GLOBAL%$string$
   :i $destroy_onscreen_keyboard$
:i endfunction


This is the function we will be editing. Change the function so it looks like this;

:i function $entered_chat_message$
:i call $GetTextElementString$ arguments
$id$ = $keyboard_current_string$
:i call $FormatText$ arguments
$TextName$ = $colour_text$
%s(5,"\cb%s")$s$ = %GLOBAL%$string$
:i call $SendChatMessage$ arguments
$string$ = %GLOBAL%$colour_text$

:i $destroy_onscreen_keyboard$
:i endfunction


# This is the vital part to the make the function work, it contains the text that changes the colour
# This is the actual text. "\cb" is a colour, and %s is $s$
# This is the part of the function that allows you to still display what you type
# This now has "$string$ = %GLOBAL%$colour_text$" instead of "$string$ = %GLOBAL%$string$"
This is because "$colour_text$ now contains %GLOBAL%$string$.


If you don't understand that, what's happening is now when $SendChatMessage$ is called (when you press enter to submit your message), The string will first call $colour_text$, and AFTER $colour_text$ is called, it will then call %GLOBAL%$string$.


If you have any chat commands (like /set, /goto /hi, etc) things will look a little different, but effectively it will be the same. Disregard this next function if you don't have /set /goto, etc commands

Code: Select all

   :i if NOT  ( (%GLOBAL%$string$ = %s(3,"/set")) )
      :i call $FormatText$ arguments
         $TextName$ = $colour_text$%s(5,"\cb%s")$s$ = %GLOBAL%$string$
      :i call $SendChatMessage$ arguments
         $string$ = %GLOBAL%$colour_text$
   :i endif
   :i $destroy_onscreen_keyboard$
:i endfunction
WhoElseButMe
Posts: 420
Joined: Tue Aug 04, 2009 12:50 am
Location: FL - USA
Contact:

Re: [THUG2][PC] Changing your default text colour.

Postby WhoElseButMe » Fri Jan 28, 2011 8:48 pm

Nice tutorial, here are some additions.
Anteara wrote:The string will first call $colour_text$, and AFTER $colour_text$ is called, it will then call %GLOBAL%$string$.

It actually calls $FormatText$ and $Colour_Text$ is your new formatted string.

A more advanced method would be to set up color as a variable and create an option in a menu to set the variable.
Example
Taking the code Anteara supplied above.
First get the preference checksum (we'll set this up later) and switch between checksums to get your text
Then change \cb to %c and add the variable to the end.

Code: Select all

:i function $entered_chat_message$
   :i call $GetPreferenceChecksum$ arguments
      $pref_type$ = $network$$TextColor$
   :i switch %GLOBAL%$checksum$
      :i case $color_ca$
         :i $color$ = %s(3,"\ca")
         :i endcase
      case $color_cb$
         :i $color$ = %s(3,"\cb")
         :i end_switch
      
   :i call $GetTextElementString$ arguments
      $id$ = $keyboard_current_string$
   :i call $FormatText$ arguments
      $TextName$ = $colour_text$%s(4,"%c%s")$c$ = %GLOBAL%$color$$s$ = %GLOBAL%$string$
   :i call $SendChatMessage$ arguments
      $string$ = %GLOBAL%$colour_text$
   :i $destroy_onscreen_keyboard$
:i endfunction

Now we need to add a variable to netoptions.qb inside default_network_preferences add
THUG2

Code: Select all

$TextColor$ = :s{$checksum$ = $color_cb$:s}

THAW

Code: Select all

StructItemStruct | ItemQbKey = TextColor |
   StructItemQbKey | ItemQbKey = checksum | QbKey = color_cb |

The variable above is checked inside entered_chat_message before the message is sent to get a color value.

Lastly we need to be able to set the color, you can do this a few different ways
I'll show the easiest method which we'll do through text commands, you could also create a menu to set the colors.
Our default color is orange or \cb so we certainly want the ability to set this one I'll also do one more.
Additional colors are left as a reader exercise.

We'll be editing entered_chat_message a little further.
Here's the code we'll be adding.

Code: Select all

:i if  (%GLOBAL%$string$ = %s(7,"/colora"))
   :i call $SetPreferencesFromUI$ arguments
      $prefs$ = $network$$field$ = %s(9,"TextColor")$checksum$ = $color_ca$
:i endif
:i if  (%GLOBAL%$string$ = %s(7,"/colorb"))
   :i call $SetPreferencesFromUI$ arguments
      $prefs$ = $network$$field$ = %s(9,"TextColor")$checksum$ = $color_cb$
:i endif

What we're doing is comparing our text string to a code if a match is made we set or network preference checksum
which will change our text color.
Here's the complete code

Code: Select all

:i function $entered_chat_message$
   :i call $GetPreferenceChecksum$ arguments
      $pref_type$ = $network$$TextColor$
   :i switch %GLOBAL%$checksum$
      :i case $color_ca$
         :i $color$ = %s(3,"\ca")
         :i endcase
      case $color_cb$
         :i $color$ = %s(3,"\cb")
         :i end_switch
      
   :i call $GetTextElementString$ arguments
      $id$ = $keyboard_current_string$
   :i if  (%GLOBAL%$string$ = %s(7,"/colora"))
      :i call $SetPreferencesFromUI$ arguments
         $prefs$ = $network$$field$ = %s(9,"TextColor")$checksum$ = $color_ca$
   :i endif
   :i if  (%GLOBAL%$string$ = %s(7,"/colorb"))
      :i call $SetPreferencesFromUI$ arguments
         $prefs$ = $network$$field$ = %s(9,"TextColor")$checksum$ = $color_cb$
   :i endif
   :i call $FormatText$ arguments
      $TextName$ = $colour_text$%s(4,"%c%s")$c$ = %GLOBAL%$color$$s$ = %GLOBAL%$string$
   :i if NOT ( (%GLOBAL%$string$ = %s(7,"/colora"))  OR  (%GLOBAL%$string$ = %s(7,"/colorb")) )
      :i call $SendChatMessage$ arguments
         $string$ = %GLOBAL%$colour_text$
   :i else
      :i call $GetPreferenceChecksum$ arguments
         $pref_type$ = $network$$TextColor$
      :i switch %GLOBAL%$checksum$
         :i case $color_ca$
            :i $color$ = %s(4,"\\ca")
            :i endcase
         case $color_cb$
            :i $color$ = %s(4,"\\cb")
            :i end_switch
         
      :i call $FormatText$ arguments
         $TextName$ = $msg$%s(24,"Text color changed to %c")$c$ = %GLOBAL%$color$
      :i call $SendChatMessage$ arguments
         $string$ = %GLOBAL%$msg$
   :i endif
   :i $destroy_onscreen_keyboard$
:i endfunction

Compile and your ready to go.
Also note that this method will save the color to your skater if you save the game after changing the text color.
Image
WhoElseButMe on Nov 26, 2009 wrote:It's that lack of respect amongst their peers and ignorance towards modding etiquette that keeps us who know this stuff well from spreading it like wild fire. We do still enjoy playing the game and if you need to cheat to play a game PLAY SOMETHING ELSE YOU DON'T SUCK AT.
Anteara
Posts: 268
Joined: Thu Oct 14, 2010 2:55 am
Contact:

Re: [THUG2][PC] Changing your default text colour.

Postby Anteara » Fri Jan 28, 2011 11:01 pm

Also, to add even more to this, I've quickly written a script which will alternate between both colours everytime you submit a piece of chat. For example, You press enter, you type "hi", you press enter again. The colour is Blue. If you press enter, type "hi", and press enter again, the colour will now be orange.

Whoelsebutme, I'm not very good at using case/switch, so if theres a better way to do this please tell.


How to have text alternating

at the start of the function, add this

Code: Select all

:i $case_Auto_Text_Colour$ = %i(0,00000000)
:i function $entered_chat_message$


This will mean that by default $case_Auto_Text_Colour$ is set to 0.

at the bottom of the function, add this

Code: Select all

   :i switch $case_Auto_Text_Colour$
      :i case %i(0,00000000)
         :i call $change$ arguments
            $case_Auto_Text_Colour$ = %i(1,00000001)
 :i call $SetPreferencesFromUI$ arguments
         $prefs$ = $network$$field$ = %s(9,"TextColor")$checksum$ = $color_ca$
         :i endcase
      case %i(1,00000001)
         :i call $change$ arguments
            $case_Auto_Text_Colour$ = %i(0,00000000)
   :i call $SetPreferencesFromUI$ arguments
         $prefs$ = $network$$field$ = %s(9,"TextColor")$checksum$ = $color_cb$
         :i end_switch


This simply means that if case = 0, it will switch it to 1, and change text colour, and if case = 1, it will switch it to 0, and change text colour back again.
WhoElseButMe
Posts: 420
Joined: Tue Aug 04, 2009 12:50 am
Location: FL - USA
Contact:

Re: [THUG2][PC] Changing your default text colour.

Postby WhoElseButMe » Sat Jan 29, 2011 12:53 am

You could do it much easier by simply adding another variable to each case in the first switch I supplied
we'll name it $next_color$ and make each value the next color checksum
Example

Code: Select all

   :i switch %GLOBAL%$checksum$
      :i case $color_ca$
         :i $color$ = %s(3,"\ca")
         :i $next_color$ = $color_cb$
         :i endcase
      case $color_cb$
         :i $color$ = %s(3,"\cb")
         :i $next_color$ = $color_ca$
         :i end_switch

Then just after the message is sent to the console set your $next_color$ preference

Code: Select all

   :i if NOT ( (%GLOBAL%$string$ = %s(7,"/colora"))  OR  (%GLOBAL%$string$ = %s(7,"/colorb")) )
      :i call $SendChatMessage$ arguments
         $string$ = %GLOBAL%$colour_text$
      :i call $SetPreferencesFromUI$ arguments
         $prefs$ = $network$$field$ = %s(9,"TextColor")$checksum$ = %GLOBAL%$next_color$
   :i else

Doing this inside the if statement will only change the color if you actually send your message to the console.
Image
WhoElseButMe on Nov 26, 2009 wrote:It's that lack of respect amongst their peers and ignorance towards modding etiquette that keeps us who know this stuff well from spreading it like wild fire. We do still enjoy playing the game and if you need to cheat to play a game PLAY SOMETHING ELSE YOU DON'T SUCK AT.
sMo0g™
Posts: 108
Joined: Fri Nov 20, 2009 1:20 pm
Location: Ukraine
Contact:

Re: [THUG2][PC] Changing your default text colour.

Postby sMo0g™ » Fri Feb 04, 2011 11:26 am

Nice tutorial (=
Good job. :clap: (y)
Siema
Posts: 26
Joined: Tue Mar 15, 2011 1:41 pm

themes menu problem

Postby Siema » Thu Jan 12, 2012 12:12 pm

I did everything correctly but for some reason like the message is not sent to the chat

Code: Select all

      :i call $FormatText$ arguments
         $TextName$ = $colour_text$%s(4,"%a%c%s%d")$a$ = %GLOBAL%$sendchat_left$$d$ = %GLOBAL%$send_chat_right$$c$ = %GLOBAL%$color$$s$ = %GLOBAL%$string$


But the color in general / cb work here is the code

Code: Select all

      :i call $FormatText$ arguments
         $TextName$ = $colour_text$%s(4,"%c%s")$c$ = %GLOBAL%$color$$s$ = %GLOBAL%$string$


why and help fix the code? :wat:

Return to “Tutorials”

Who is online

Users browsing this forum: No registered users and 2 guests