MODULE: GuiPortrait v1.00: Show Sierra portraits on a GUI

Started by SSH, Wed 02/07/2008 11:19:48

Previous topic - Next topic

SSH

Well, CJ may fix this in AGS 3.03 or somesuch, but meanwhile, GUIs appear on top of Sierra-tyle speaking view portraits, but behind the text, which can look odd. This module works around the problem by using a GUI to display your Speech View.

Thanks to Dave Gilbert for raising the issue.

The GuiPortrait module


Let me know if you need any additional features!
12

naltimari

I've made a similar module to my game myself. Yours is easier to use, since it does not require almost any effort from the game designer besides importing the GUI (or creating one and naming it accordingly).

But in my module I ended up using two features that now seem very cool:

  • I used a button as a 'placeholder' for the character, so I can place it exactly where I want inside the GUI. Like centered, for example. Or, if the GUI background is customized, I can place it at the corner, inside a box, you name it.
  • Since I can place the character anywhere, I can place the text too, using a Label as a placeholder.

    I thought these two would be great additions to your module, and the 'installation' is not that hard for the end user, all you have to do is name the controls accordingly.

    As to why I didn't release my module so far, well, I wanted it to have a 'back/forward/skip' feature as well, and I had a hard time doing it. It is now almost complete...

    * Note: now I realize my module has a WaitMouseKey(), because the 'normal' behaviour of Say() is to wait for a user interaction. If you remove the 'Say()' from yours, you have to do it as well.

SSH

If you don't use Say, how do you display the text?
12

naltimari

Quote from: SSH on Fri 04/07/2008 20:00:53
If you don't use Say, how do you display the text?

I place the text inside the Label that is in the GUI. You see, I placed one Label there specifically to act as a placeholder for the text.

When the user calls 'SayGUI(text)', the method fills the text inside the label, and it keeps calling WaitMouseKey() while changing the talking sprite, just like you did.

naltimari

Quote from: naltimari on Fri 04/07/2008 20:07:10
When the user calls 'SayGUI(text)', the method fills the text inside the label, and it keeps calling WaitMouseKey() while changing the talking sprite, just like you did.

Now I realized I could have used Button.Animate() to make the character 'talk' instead of changing the sprites explicitly...

SSH

So, your one isn't compatible with voice packs? Mine was primarily made for Dave G, and I know that he needs voice support...
12

naltimari

Quote from: SSH on Fri 04/07/2008 23:27:15
So, your one isn't compatible with voice packs? Mine was primarily made for Dave G, and I know that he needs voice support...

What are 'voicepacks'? I've never heard of them...  ;D

Anyway, no, it was not my intention to use it, simply because I never knew such thing existed.

SSH

Also, the way I do it supports blink views, which Dave also has, which is why I go to the bother of Animating by hand. Its horses for courses, really: Dave just wanted things the same as the built-in, but on top of GUIs, you wanted more graphical effects...
12

Dualnames

Sorry for the bump, but I'm doing this:

Code: ags

function SayCustom(String type) {
SmoothScroll_StopScroll();
player.StopMoving();
SetSpeechStyle(eSpeechSierraWithBackground);
gDeleteThis.Visible=false;
//cNa.Say(type);
cNa.GSay(type, cNa.View, 0);
SetSpeechStyle(eSpeechLucasarts);
gDeleteThis.Transparency=100;//Overhotspot GUI
gDeleteThis.Visible=true;

}



And it's not working at all.
The Z Order of the inventory is just 1.

And by default importing the Portrait gui, the portrait GUI has 200.
However the speech is displayed like it was without the GUI.

I use eLucasArtSpeech style for all the rest of the characters but Narrator (cNa).
There's no code affecting the zOrder.

I'm terribly sorry for the bump, but I just thought this be important to the rest.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

SSH

Can you send me a zip of the game?

Quote from: Dualnames on Tue 04/05/2010 15:02:09
Sorry for the bump, but I'm doing this:

Code: ags

function SayCustom(String type) {
SmoothScroll_StopScroll();
player.StopMoving();
SetSpeechStyle(eSpeechSierraWithBackground);
gDeleteThis.Visible=false;
//cNa.Say(type);
cNa.GSay(type, cNa.View, 0);
SetSpeechStyle(eSpeechLucasarts);
gDeleteThis.Transparency=100;//Overhotspot GUI
gDeleteThis.Visible=true;

}



And it's not working at all.
The Z Order of the inventory is just 1.

And by default importing the Portrait gui, the portrait GUI has 200.
However the speech is displayed like it was without the GUI.

I use eLucasArtSpeech style for all the rest of the characters but Narrator (cNa).
There's no code affecting the zOrder.

I'm terribly sorry for the bump, but I just thought this be important to the rest.
12

Dualnames

Quote from: SSH on Wed 05/05/2010 02:34:12
Can you send me a zip of the game?

Quote from: Dualnames on Tue 04/05/2010 15:02:09
Sorry for the bump, but I'm doing this:

Code: ags

function SayCustom(String type) {
SmoothScroll_StopScroll();
player.StopMoving();
SetSpeechStyle(eSpeechSierraWithBackground);
gDeleteThis.Visible=false;
//cNa.Say(type);
cNa.GSay(type, cNa.View, 0);
SetSpeechStyle(eSpeechLucasarts);
gDeleteThis.Transparency=100;//Overhotspot GUI
gDeleteThis.Visible=true;

}



And it's not working at all.
The Z Order of the inventory is just 1.

And by default importing the Portrait gui, the portrait GUI has 200.
However the speech is displayed like it was without the GUI.

I use eLucasArtSpeech style for all the rest of the characters but Narrator (cNa).
There's no code affecting the zOrder.

I'm terribly sorry for the bump, but I just thought this be important to the rest.

Yes, but there's high chance you don't survive. :D
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Dualnames

Also fixed. I used this:

cNa.GSay(type);

Instead of setting an optional view, and now it works greatness!!
Thanks SSH!!
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Knox

First off Id like to say this is a great module!!

Im not sure if Im the only one but it seems that when the guiportrait is "in action" over a GUI, the framerate drops about 10fps...is this what other people are getting as results?

Of course, Ive got some tween animations running in the backgrouns aswell (on the gui that is behind the guiportrait).
--All that is necessary for evil to triumph is for good men to do nothing.

Dualnames

Quote from: general_knox on Mon 17/05/2010 16:46:57
First off Id like to say this is a great module!!

Im not sure if Im the only one but it seems that when the guiportrait is "in action" over a GUI, the framerate drops about 10fps...is this what other people are getting as results?

Of course, Ive got some tween animations running in the backgrouns aswell (on the gui that is behind the guiportrait).

General knox, I'm not getting anything with that. And I'm using the Tween module and several other things going on such as particle effects. Perhaps there's a way for you to fix this.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Knox

Ok Ill try to debug this then...its something that I put off on my todo list for too long.

I hope I find the prob :P
--All that is necessary for evil to triumph is for good men to do nothing.

AdamM

Trying to get lip-sync in this module... seems to work for me, although I had to hard-code the syllable detection and which frame corresponds to which syllable... I'm not the best scripter in the world SSH, of course.

Code: ags

String Portrait_Workspace;
int Portrait_Reduction;
int Portrait_LSFrame;
String LipSyncMessage;
int Portrait_IsEndOfSpeech;

...

function Portrait_LipSync(String what) {
  Portrait_Workspace = what.Substring(Portrait_Reduction, (what.Length-1));
  Portrait_LSFrame = -1;
  String Portrait_vls = Portrait_Workspace.Truncate(2);  //Two-letter syllable
  if (Portrait_IsEndOfSpeech==1) {Portrait_LSFrame=0;}
  else if ((Portrait_vls.CompareTo("ph")==0)) {Portrait_LSFrame=2;}
  else if ((Portrait_vls.CompareTo("ch")==0)) {Portrait_LSFrame=5;}
  else {
    Portrait_vls = Portrait_Workspace.Truncate(1);   //Not two-letter syllable
    if ((Portrait_vls.CompareTo(".")==0) || //M sound
    (Portrait_vls.CompareTo("?")==0) || 
    (Portrait_vls.CompareTo("!")==0) || 
    (Portrait_vls.CompareTo(",")==0) || 
    (Portrait_vls.CompareTo("B")==0) || 
    (Portrait_vls.CompareTo("K")==0) || 
    (Portrait_vls.CompareTo("Q")==0) || 
    (Portrait_vls.CompareTo("D")==0) || 
    (Portrait_vls.CompareTo("P")==0) || 
    (Portrait_vls.CompareTo("M")==0))
    {Portrait_LSFrame=0;}
    else if ((Portrait_vls.CompareTo("L")==0) || //Tongue sound
    (Portrait_vls.CompareTo("T")==0) || 
    (Portrait_vls.CompareTo("R")==0) || 
    (Portrait_vls.CompareTo("S")==0) || 
    (Portrait_vls.CompareTo("J")==0) || 
    (Portrait_vls.CompareTo("N")==0) ||
    (Portrait_vls.CompareTo("3")==0) || 
    (Portrait_vls.CompareTo("9")==0))
    {Portrait_LSFrame=1;}
    else if ((Portrait_vls.CompareTo("F")==0) || //F sound
    (Portrait_vls.CompareTo("V")==0) || 
    (Portrait_vls.CompareTo("4")==0) ||
    (Portrait_vls.CompareTo("5")==0))
    {Portrait_LSFrame=2;}
    else if ((Portrait_vls.CompareTo("W")==0) || //O sound 
    (Portrait_vls.CompareTo("U")==0) || 
    (Portrait_vls.CompareTo("O")==0) || 
    (Portrait_vls.CompareTo("0")==0) ||
    (Portrait_vls.CompareTo("1")==0) || 
    (Portrait_vls.CompareTo("2")==0))
    {Portrait_LSFrame=3;}
    else if ((Portrait_vls.CompareTo("G")==0) || //A sound
    (Portrait_vls.CompareTo("A")==0) || 
    (Portrait_vls.CompareTo("H")==0) || 
    (Portrait_vls.CompareTo("Y")==0) || 
    (Portrait_vls.CompareTo("8")==0))
    {Portrait_LSFrame=4;}
    else if ((Portrait_vls.CompareTo("E")==0) || //E sound
    (Portrait_vls.CompareTo("X")==0) || 
    (Portrait_vls.CompareTo("I")==0) ||  
    (Portrait_vls.CompareTo("3")==0) || 
    (Portrait_vls.CompareTo("6")==0) || 
    (Portrait_vls.CompareTo("7")==0))
    {Portrait_LSFrame=5;}
    else {Portrait_LSFrame=4;}
  }
   Portrait_Reduction=(Portrait_Reduction+Portrait_vls.Length);
   if (Portrait_Reduction>=what.Length) {Portrait_IsEndOfSpeech=1;}
}

function Portrait_DoFrame() {
    Portrait_vf=Game.GetViewFrame(Portrait_View,  Portrait_Loop, Portrait_LSFrame); //changed Portrait_Frame to Portrait_LSFrame
...
}

function repeatedly_execute_always() {
...
      Portrait_LipSync(LipSyncMessage);
      Portrait_DoFrame();
...
}

function GSay(this Character *,  String what,  int view,  int loop) {
    LipSyncMessage=what;
    Portrait_IsEndOfSpeech=0;
    Portrait_Reduction=0;
...
}

SSH

rather than this...

Quote from: AdamM on Wed 09/06/2010 16:53:22
Code: ags

    Portrait_vls = Portrait_Workspace.Truncate(1);   //Not two-letter syllable
    if ((Portrait_vls.CompareTo(".")==0) || //M sound
    (Portrait_vls.CompareTo("?")==0) || 
    (Portrait_vls.CompareTo("!")==0) || 
    (Portrait_vls.CompareTo(",")==0) || 
    (Portrait_vls.CompareTo("B")==0) || 
    (Portrait_vls.CompareTo("K")==0) || 
    (Portrait_vls.CompareTo("Q")==0) || 
    (Portrait_vls.CompareTo("D")==0) || 
    (Portrait_vls.CompareTo("P")==0) || 
    (Portrait_vls.CompareTo("M")==0))
    {Portrait_LSFrame=0;}
    else ...


why not...

Code: ags

    Portrait_vls = Portrait_Workspace.Truncate(1);   //Not two-letter syllable
    String mmatch=".?!,BKQDPM";
    if ((mmatch.IndexOf(Portrait_vls)>=0) Portrait_LSFrame=0;
    else ...


Or you could even set up mmatch as a static String array and iterate over it, with the frame number matching the array index.  ;)
12

AdamM

I was waiting for someone to point out a better way of doing that, thanks.

Knox

Im not sure but I think I ran into a bug(?) with this module:

In a dialog, if I use the standard "Say", this works:
Code: ags

// Dialog script file
@S  // Dialog startup entry point
  player.Say("I am saying this code: %s", sSayCode);
  cDispatch.Say("Im a dispatcher responding negatively to code: %s", sSayCode);
return

@1
  endConvo();
stop


...but if I run the same as above but using "GSay" instead of "Say", I get this error:
Code: ags

Dialog 10(3): Error (line 3): Type mismatch: cannot convert 'String*' to 'int'
--All that is necessary for evil to triumph is for good men to do nothing.

SSH

GSay doesn't have the styring formatting capability of Say and can't, due to restrictions in the way that user-defined functions can take arguments. If you want to do what  you're trying to do:

Code: ags

player.GSay(String.Format("I am saying this code: %s", sSayCode));


12

Knox

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

Knox

Hi SSH,

Just wanted to know if I can replace the following line #89 (Portrait_AnimSpeed=this.AnimationSpeed) to (Portrait_AnimSpeed=this.SpeechAnimationDelay) within my copy of your script:

Code: ags

function GSay(this Character *,  String what,  int view,  int loop) 
{
    if (view<1) view=this.SpeechView;
    Portrait_Frame=0;
    Portrait_Loop=loop;
    Portrait_View=view;
    //Portrait_AnimSpeed=this.AnimationSpeed;
    Portrait_AnimSpeed=this.SpeechAnimationDelay;


Id rather modify the speed of the speech with the speech animation delay rather than the character's movement speed.
--All that is necessary for evil to triumph is for good men to do nothing.

SSH

Do it and I'll sue  ;D

Sure, go ahead. Do you think that this should be changed in my version, too?
12

Knox

haha! ;D

Nah, unless other peeps want to...Ill just do it to my copy :P

Thanks!!

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

Knox

Sorry for the double post but if I just edited my last post perhaps it wouldnt get noticed.

So far the caveats are:

Lip-synch not supported
Thinking views not supported

Again, I might be wrong, but it seems to me that delays that are set for each frame within the speech views seem to be ignored...is that possible? I mean, I can see it animate fine with all  the proper delays in the preview, and if I use .Say...but if I use GSay, those delays seem to be set to 0, or just bypassed/not taken into account (?).

Try making a view where one of the frames has a delay set to something noticebly long (like 120, for example)...its *seems* to me, anyway, that the delay will be ignored.

Anyways, perhaps if you have time you can check this out? Maybe Im doing something wrong :P
--All that is necessary for evil to triumph is for good men to do nothing.

SSH

On looking at the code, the speech view should include each frame delay (Portrait_Counter=Portrait_AnimSpeed+Portrait_vf.Speed+1;) but I probably didn't test that so there may be a problem (e.g. it uses the previous or next frame's speed is one I could imagine)

Another issue is, though, that it perhaps ignores the speed for blink frames.

12

Knox

Ahh, thats it...I checked it out, it is for the blink view!

So, is this another "caveat" or can something be done to add delays on frames for blink views?

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

Priabudiman

i find my portrait are displayed behind GUI, ive tried to download the script here but the compiler give me an error

Code: ags
GuiPortrait.asc(24): Error (line 24): Undefined token 'gPortrait' 


i assume AGS hasnt fixed this problem and the script are outdated?

Khris

The download includes a *.guf file; that's a GUI you need to import into your game. The GUI will have the script name "gPortrait", which will resolve the error you got.

shaun9991

Sorry to drag up an older post. If using this module, is there some way of auto-numbering speech lines? Can speech (as in voice acting) be used at all on custom speech gui's like this?

Many thanks,
Shaun
Support Cloak and Dagger Games on Patreon: https://www.patreon.com/user?u=460039

Blue Bee

Sorry for bumping this but does anyone have a working download link for this module? The original link seems to be broken and I can't find any copies anywhere.

Thanks



Crimson Wizard

And again (for the second time, I guess) I suggest making a central repository for AGS scripting modules (especially lost ones) :).

SMF spam blocked by CleanTalk