Different Color+Font for different characters

Started by Knox, Tue 26/05/2009 00:38:14

Previous topic - Next topic

Knox

Hi,

I found some topics discussing how to change the text color, or even the speech color. What I would like to know is, is there a "simple" way of having different characters linked to different speech colors + their own font? Im using a custom text window, and its color is black. So when I use the "sierra with background" in the settings, the character's speech is black (of course). When I choose "sierra transparent", then I can have different colors because there is a place to set that up in the character's options.

Is there a way to keep the custom text window, but override the text color assigned to that custom text window with each character's own text color setting?

During a dialog, with a custom text window, when Character A speaks, he has font A and color A...when Character B speaks in response, she has font B and color B...

If this isnt possible via the menus (no scripting), this is something that we should implement in the next version of AGS!

*ps: in the meantime, if this is possible via scripting only, Ill take that route if I dont have any other choice until it is implemented!

:)


--All that is necessary for evil to triumph is for good men to do nothing.

Ghost

#1
SSH's HyperText module can do that, and the usage is pretty simple. With the default AGS settings/tools, you can't do it at all- you'd need to do at least some basic scripting, checking against a certain character being active and then changing font/colour. Perfectly possible, but then you might as well use HyperText.

From SSH:
I have created a module that allows you to display marked-up text that can change font or colour in the middle and back again, also with Hyperlinks. v1.1 includes support for functions that work like character.Say() and Display(). Also, new strikethrough, bold, overline, etc. special effects.

Find it here:
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=29358.0

Knox

I got the customGUI to work pretty quickly, however, I find this module difficult...pardon my ignorance!

I dont really understand "where" to put my values...I see:

static function Hypertext::SetPrefixStyle(char prefix, int font, HypertextSpecialT special, int r, int g, int b, int bgr, int bgg, int bgb) {
  Style[prefix].font=font;
  Style[prefix].r=r;
  Style[prefix].g=g;
  Style[prefix].b=b;
  Style[prefix].set=true;
   Style[prefix].special=special;
   Style[prefix].bgr=bgr;
   Style[prefix].bgg=bgg;
   Style[prefix].bgb=bgb;
}

...but do I plug my desired values after the "=" ? as in:

static function Hypertext::SetPrefixStyle(char prefix, int font, HypertextSpecialT special, int r, int g, int b, int bgr, int bgg, int bgb) {
  Style[prefix].font=0;
  Style[prefix].r=0;
  Style[prefix].g=0;
  Style[prefix].b=1;
  Style[prefix].set=true;
   Style[prefix].special=special;
   Style[prefix].bgr=bgr;
   Style[prefix].bgg=bgg;
   Style[prefix].bgb=bgb;
}

If not, I think I need a walkthrough cause I just dont get it (sorry guys).

Ive got a background in mel scripting but I am just starting with this, so me needs patience :)

Lets say for starters I just want to make character A have color A and font A...on my own custom text window. Where do i place the script line? Within the Hypertext.asc, or in GlobalScript?

I'll continue searching on my own though, dont want to annoy anyone!

:)
--All that is necessary for evil to triumph is for good men to do nothing.

Khris

You're usually not supposed to edit a module. What modules do is provide additional functions; call them like you would built-in ones.

So you're supposed to do e.g.
Code: ags
  Hypertext.SetPrefixStyle(player.ID, 0, special, 255, 0, 0, 30, 30, 30);


This won't work as is; see the documentation for an explanation of the parameters.

Knox

Ok, so I would place that line of script into the GlobalScript.asc somewhere...or another place?

I tried to launch the demo that came with the zip, but I get this error
(I didnt modify anything at all):

Module5.asc(45): Error (line 45): '.info' is not a public member of 'Idles'. Are you sure you spelt it correctly (remember, capital letters are important)?
--All that is necessary for evil to triumph is for good men to do nothing.

Trent R

You put the line where ever you want to change the text color (or other settings). So if you wanted to be able to switch the player's character on an Options GUI, you can do that.

I'd suggest game_start in your global.


~Trent
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

Knox

#6
I guess Im really really retarded cause I just dont get it! (slaps face with hands in shame)

I put this in the game_start in GlobalScript:

function game_start() {  

 initialize_control_panel();

 KeyboardMovement.SetMode(eKeyboardMovement_Tapping);

 Hypertext.SpeechStyle(eSpeechSierra, 200);
 Hypertext.SetPrefixStyle(player.ID, 0, true, 255, 0, 0, 30, 30, 30);

}

Speech Style is set to  "SierraWithBackground" in General Settings. From what I understand, the "200" is for the y position of the text in sierra speech, but the custom textwindow I made still displays at the same place (near the top)...plus, player.ID: is that like "cEgo" names, or their number?

I ran it but nothing changed...I know I TOTALLY dont get this, I read the documentation and theres something I dont get. Again, I apologize for probably sounding really stupid, me dont gets it...sniff sniff!!

Is a dumbed-down walkthrough setp-by-step possible for retards like me? Hehe...Im sure a light will click on and things will clear up eventually, doh!


 

This is what I have now...black text on a custom text window. Id like to move the window down so its under the portrait of the characters (not next to them), and the police officer's speech color is blue with a different font, and the woman's speech text color is pink with also her own different font.

I'll return the favor one day to you guys...:)
--All that is necessary for evil to triumph is for good men to do nothing.

Trent R

#7
QuoteSpeech Style is set to  "SierraWithBackground" in General Settings.
I'm guessing this is the problem... It's possible the Hypertext speech style is being overridden by the General Settings.

I'm DLing it now so that I can read the manual myself and hopefully be more useful.


[Edit]: Okay, so the General Setting isn't the problem, I think SetPrefixStyle is. Did you even read the manual entry for it? Where'd you get that you needed player.ID there, or even that 'true' parameter?
Quote
//   SetPrefixStyle allows you to set the way text is printed according to markup.
//   You can use any character you like as a markup character, but you should avoid
//    characters that you are likely to use at the beginning or end of words in the
//    normal course of events. Some possibilities are ^_*{}+=@~#/<>\| but it depends
//    on your game. By default, _*+ are set up. _ has a special meaning of indicating
//    a link, also.

[Rest of entry omitted for post]


Try putting this in your game start. If I understand the module correctly, it should work.
Code: ags

  Hypertext.SetPrefixStyle('^', 0, eHypertextSpecial_None, 255, 0, 0, 30, 30, 30);
  Display("Here is a Hyper^Display in two colors.");


~Trent
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

Knox

Hi Trent,

If at anytime you would prefer PM, let me know!

Thanks for your response. I did what you wrote, that works, but every character is black...also, I tried changing the values of colors, or fonts...the same effect is given regardless. Black text on my custom text window, same font...and the same font no matter what I change as value. For example, this code gives me this effect at startup:

Hypertext.SetPrefixStyle('^', 0, eHypertextSpecial_None, 255, 0, 0, 30, 30, 30);
  Display("Here is a Hyper^Display in two colors.");



This modified values script gives me the same effect, however!

Hypertext.SetPrefixStyle('^', 2, eHypertextSpecial_None, 255, 255, 255, 0, 0, 0);
  Display("Here is a Hyper^Display in two colors.");

Im guessing the CustomDialogGui script is interfering with the Hypertext script (?)

--All that is necessary for evil to triumph is for good men to do nothing.

GarageGothic

Quote from: general_knox on Thu 28/05/2009 17:30:39I did what you wrote, that works, but every character is black..

What are you? Racist?  ;D

Knox

--All that is necessary for evil to triumph is for good men to do nothing.

SMF spam blocked by CleanTalk