Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest WME version: WME 1.9.1 (January 1st, 2010) - download

Pages: [1] 2  All

Author Topic: "Subtitle" style dialog  (Read 15886 times)

0 Members and 1 Guest are viewing this topic.

Marek

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 61
  • I'm a llama!
    • View Profile
"Subtitle" style dialog
« on: August 20, 2004, 08:23:58 PM »

I'm modifying the Talk function in an attempt to show the text centred at the bottom of the screen, along with the name of who is doing the talking.

I'm approaching this the same way as described in this thread.
However, I don't want to specify the duration for each line. It should work by default like the normal Talk function.

Does the WME scripting language have a function for counting the number of characters in a string? I'm guessing no since it's not in the manual, but who knows. I need a way to have an adaptive default duration for my hacked talk function. If there's another way let me know.

Okay, second issue is having the name there of the character who is talking.
First I was thinking I should do something like

if actor isTalking --> char = "Mike"
load entity Sally
if Sally isTalking --> char = "Sally"
load entity Larry
if Larry isTalking --> char = "Sally"
etc. [not actual code, obviously]

But that seems so awkward and wrong that I haven't even tried it yet.
Is there an easy way to retrieve the name of the object that is talking at any time?

Thanks for the assistance, as usual.

Marek
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: "Subtitle" style dialog
« Reply #1 on: August 20, 2004, 09:56:53 PM »

All string variables actually provide a .Length attribute, returning the number of characters in the string. But perhaps it would be better to override the default Talk method, since it uses an adaptive duration already (if no duration is explicitly specified). You could simply change the subtitles position of your actors/narrator using their SubtitlesPosRelative, SubtitlesPosX, SubtitlesPosY and SubtitlesWidth attributes, so that they are displayed at the bottom of the screen.

As for the character name, again overriding the Talk method should do the trick. Adding the following code to the scripts attached to your actors:

Code: [Select]
method Talk(Text)
{
  // add actor's caption to the speech text
  Text = this.Caption + ": " + Text;
 
  // and call the built-in Talk method with the modified text
  this.Talk(Text);
}

This is just an example, I don't know what exactly do you want to do with the character name.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Marek

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 61
  • I'm a llama!
    • View Profile
Re: "Subtitle" style dialog
« Reply #2 on: August 20, 2004, 11:09:32 PM »

Umm, okay. In that case, things appear to be infinitely less complex than I imagined them to be. Thanks, I'll go to work on this!
Logged

Marek

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 61
  • I'm a llama!
    • View Profile
Re: "Subtitle" style dialog
« Reply #3 on: August 21, 2004, 10:04:51 PM »

Okay, what I'd like to do with the name of who's talking is to put it above the dialog text in a different font.

I could make a window and a displaytext function for that, just like with the narrator thing. Trouble is ... I don't know how to make it display exactly as long as the this.Talk(Text); ...
That's all I can think of :o

What's the easiest way to do this?
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: "Subtitle" style dialog
« Reply #4 on: August 22, 2004, 06:52:26 AM »

Well, if you used an overriden Talk method instead of the window approach (as suggested above), the font assigned to each character would be used automatically.

If you use the window approach, as described in the narrator thread, you'd have to use character's GetFont method to get the filename of the current font and then use the SetFont method of the static control you use to display the text.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Marek

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 61
  • I'm a llama!
    • View Profile
Re: "Subtitle" style dialog
« Reply #5 on: August 22, 2004, 12:22:41 PM »

I'm taking the overriden talk method approach. I get what you mean. What I want to do is perhaps better explained with a picture...

Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: "Subtitle" style dialog
« Reply #6 on: August 22, 2004, 01:10:23 PM »

I created a small demo with subtitles, try it here: http://dead-code.org/download/demos/wme_subtitles_demo.rar

All the important code is in the "actors\molly\talk.script". Basically you should only need to attach this script to your actors (and perhaps change the window/subtitles position).
This script uses a fixed color for speaker name and various colors for the actual speech. It would need to be modified if you wanted it the other way around.
« Last Edit: August 23, 2004, 05:40:35 PM by Mnemonic »
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Marek

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 61
  • I'm a llama!
    • View Profile
Re: "Subtitle" style dialog
« Reply #7 on: August 22, 2004, 03:01:20 PM »

That's beautiful. It interferes with my responses window though.

I tried WinSubtitles.Interactive = false; and WinSubtitles.Transparent = true; and such, but it won't send the clicks through to my responses window.
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: "Subtitle" style dialog
« Reply #8 on: August 22, 2004, 03:12:05 PM »

Oops, my mistake :-[ Modified the script to hide the window after talking.

Code: [Select]
#include "scripts\base.inc"

global WinSubtitles;
var Static;

// create a window for subtitles if it doesn't exist yet
if(WinSubtitles==null)
{
WinSubtitles = Game.CreateWindow("subtitles_window");
Static = WinSubtitles.CreateStatic("speaker_name");

// position the subtitles window
WinSubtitles.X = 0;
WinSubtitles.Y = Game.ScreenHeight - 100;
WinSubtitles.Width = Game.ScreenWidth;
WinSubtitles.Height = 100;
WinSubtitles.Visible = false;

// position the speaker name
Static.X = 0;
Static.Y = 0;
Static.Width = Game.ScreenWidth;
Static.Height = 20;
Static.TextAlign = TAL_CENTER;
Static.SetFont("fonts\outline_white.font");

Static.Text = "";
}
else Static = WinSubtitles.GetControl("speaker_name");

// position of actors' speech subtitles
this.SubtitlesPosX = 0;
this.SubtitlesPosY = WinSubtitles.Y + 20;
this.SubtitlesPosRelative = false;
this.SubtitlesWidth = Game.ScreenWidth;


////////////////////////////////////////////////////////////////////////////////
// an overriden Talk method to display the speaker name
////////////////////////////////////////////////////////////////////////////////
method Talk(Text, SoundFilename, Duration, TalkStances, TextAlignment)
{
WinSubtitles.Visible = true;

Static.Text = this.Caption;
this.Talk(Text, SoundFilename, Duration, TalkStances, TextAlignment);
Static.Text = "";

WinSubtitles.Visible = false;
}
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

tnomad

  • Studio Trophis
  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 18
    • View Profile
    • Studio Trophis
Re: "Subtitle" style dialog
« Reply #9 on: September 04, 2004, 03:47:45 PM »

I've been trying to do this subtitlte dialog thing, however I can't seem to get 'this.SubtitlesPosX' to work correctly. No matter what I set this value to, the subtitles always seem to end up aligned with the left hand side of the screen.

So I don't know if this a bug or me missing something here...  :(
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: "Subtitle" style dialog
« Reply #10 on: September 04, 2004, 04:17:57 PM »

I've been trying to do this subtitlte dialog thing, however I can't seem to get 'this.SubtitlesPosX' to work correctly. No matter what I set this value to, the subtitles always seem to end up aligned with the left hand side of the screen.

So I don't know if this a bug or me missing something here...  :(

And how exactly does your code look like and where is it located?
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

tnomad

  • Studio Trophis
  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 18
    • View Profile
    • Studio Trophis
Re: "Subtitle" style dialog
« Reply #11 on: September 04, 2004, 04:41:58 PM »

I just used that code from two posts above, put it in the actor script.

And I was trying to use the SubtitlesPosX and SubtitlesWidth values to have some left alignd text that goes in a box that is offset from the edge of the screen.

If it works for you then fair enough, I just wanted to check if it was a bug or if I was missing something...
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: "Subtitle" style dialog
« Reply #12 on: September 04, 2004, 05:44:52 PM »

Well, I was testing it and the problem is probably that the SubtitlesPosX specifies the *center* of the subtitle, not its left edge. It's confusing and perhaps unnecessary in case of absolute subtitles positioning. I'll make this behavior optional in the next release.

Anyway, to overcome this, increase your SubtitlesPosX value by a half of the SubtitlesWidth value. For example if your subtitle width is 500 and you want the left edge of the subtitles at 100 pixels, set SubtitlesPosX to 350 (100 + 500/2).

Sorry for the confusion, I didn't realize that before.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

tnomad

  • Studio Trophis
  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 18
    • View Profile
    • Studio Trophis
Re: "Subtitle" style dialog
« Reply #13 on: September 04, 2004, 07:15:00 PM »

Thanks, that's it...

Yeah I agree it's a little confusing though I'm kicking myself for not checking if it was a centre value, but the example code being set to 0 misled me.

Glad you plan to improve this for the next release...
Logged

tnomad

  • Studio Trophis
  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 18
    • View Profile
    • Studio Trophis
Re: "Subtitle" style dialog
« Reply #14 on: December 19, 2004, 03:24:55 PM »

I've been using this code Mnemonic provided in my project for some time now but I've had an outstanding bug with it that I've finally been looking at today and after a few hours working on it I'm not getting anywhere so I thought I'd post here to see if I can get any help.

I'm using an adpated version of the code provided to make a "WinSubtitles" window that includes a nice image background while the character is talking. Now it works fine under normal usage, when the character talk method is called the overridden talk method shows the image window and displays the subtitles and then makes them disappear when the dialogue is finished.

However if the user clicks to walk away while the text is being shown then the subtitle text will disappear but the WinSubtitles image window does not.

I've tried using the istalking method in the daemon script to make sure the WinSubtitles image is not shown when it is not relevant but I can't write anything that works. If I knew how to get a block inside the daemon script that only ran when the character is talking I guess I could get this working, but if(!actor.IsTalking) didn't seem to work.

I would really really appreciate some help with this if possible...
Logged
Pages: [1] 2  All
 

Page created in 0.03 seconds with 23 queries.