Jump to content

How to subtitle dialogs in Leadwerks...


Russell
 Share

Recommended Posts

Hello team!!

It has been a long time since I was connected here. I hope you are all OK. That no one has been touched by the damn COVID.

This week I have finally resumed my work with LEADWERKS, and I want ask you if there is a tutorial, or a site in the WIKI (Learn) that shows how create and display SUBTITLES on the screen inside our games. Is possible?
I want to subtitle in English all the dialogues that I have recorded in Spanish in my game. But I can't find anything in GOOGLE, or in the WIKI (Learn), or here in the FORUM.

Thank you, and I hope you are doing well!

Cheers!!

  • Like 1
Link to comment
Share on other sites

2 hours ago, Josh said:

What part are you having trouble with?

At this moment in my game i have a simple subtitle system using 4 elements:

  • A button.
  • An audio message.
  • An alpha texture with the subtitle in.
  • A timer with X seconds. (Where X is the lenght of the audio message)

When we push the button, the audio message plays, the texture with the Subtitle appears on screen and the timer is ENABLED, and the the Button is DISABLED.

After the timer is over, the subtitle texture hiddes.

This is my WORKFLOW working ok:

workflow.jpg.720663ac9cc54f8ad7157c27572bc418.jpg

 

And this is my result using my own DESIGN of the HUD and SUBTITLES writen inside:

20200920133706_1.thumb.jpg.16bda5eca90bf9b9f877b9a7eb8b236c.jpg

This is my SCRIPT CODE for show the subtitles:

Script.enabled = true --bool "Enabled"
Script.HudTextura=""--string "Nombre Textura"

local MostradaImagen="No"

function Script:Start()
	if self.enabled==true then
		self.enabled=true
	else
		self.enabled=false
	end
	--EMPTY TEXTURE
	textureVacia = Texture:Load("Materials/MisTexturas/TexturaVacia.tex")
end

function Script:Enable()--in
	if self.enabled==false then
		MostradaImagen="Yes"
		ImagenTextura = Texture:Load("Materials/MisTexturas/Subtitulos/"..self.HudTextura..".tex")
		self.enabled=true
	end
end

function Script:Disable()--in
	if self.enabled==true then
		MostradaImagen="No"
		ImagenTextura = Texture:Load("Materials/MisTexturas/TexturaVacia.tex")
		self.enabled=false
	end
end

function Script:PostRender(context)
	if MostradaImagen=="Yes" then
		context:SetBlendMode(Blend.Alpha)
		context:DrawImage(ImagenTextura,0,0,context:GetWidth(),context:GetHeight())
	end
	if MostradaImagen=="No" then
		context:SetBlendMode(Blend.Alpha)
		context:DrawImage(textureVacia,context:GetWidth()/2-textureVacia:GetWidth()/2,context:GetHeight()/2-textureVacia:GetHeight()/2,textureVacia:GetWidth(),textureVacia:GetHeight())
	end
end

 

My trouble at this point is, i'm using one image for each subtitle, for each dialog. The only change in all of the images i'm using is the TEXT in Spanish or English for each subtitles and for each dialog appear in my game.

I want use ONE single image with the FRAME of the SUBTITLES (like the screenshot but WITHOUT text). And then use LABEL ENTITY (or another) with LABEL_WRAP property for SHOW all of each subtitles i want write inside.

I have tried using LABEL, using DRAWTEXT on Context. But i don't know how code them to make succesfull the APPEAR and HIDDE of the TEXT for each subtitle.

I don't know how use them...

Thanks a lot Josh!! Nice to read you again after my absence these last months.

Link to comment
Share on other sites

58 minutes ago, Marcousik said:

Hello Russel

This is pretty simple: Leave a transparent place in your texture where the text should be written. Draw the texture in blend mode.

Then write the text with Context:DrawText() after declaring a Font:Load() varaible. So you can write and change your text as you want.

Hello Marcousik!! Nice to read you again!!

Despite being simple, I can't create a script to write text in the frame that I have designed for our character's dialogues. (Dialogs of several lines that fit the designed box)

Ejemplo.thumb.jpg.c14fa3999411a19b9f4cbffaf1e1a32e.jpg

As you can see in the screenshot, I have already used DrawText () for the texts that are at the bottom left:
"Outside of the FotoMuseo"
"FotoMuseo 3D - Exterior FotoMuseo"

But if I want to write text inside that Frame box, I don't know how can align it, nor how I use the WRAP parameter and make it look good and fixed to the inside of the frame.

At this moment, and until I learn how to program a Script that fits the text in this FRAME, I am using transparent images with text (for each dialog).

So I can leave it like this:

Llave.thumb.jpg.be4627c61820756288083195aa27f97b.jpg

 

Or even display images in the text box like this too:

Dragon.thumb.jpg.c61d2e021115174957229b5b170dd2e9.jpg

 

But no idea how write any TEXT in the Frame using CODE (which is what I want to do) and make it look good and fixed to the inside of the frame.

Thanks a lot!!

Link to comment
Share on other sites

Ok look at the function description, I think you forgot something very easy:

https://www.leadwerks.com/learn?page=API-Reference_Object_Context_DrawText

  • DrawText(string text, number x, number y, number kerning=1.0)

> The x,y are what you are seeking I suppose, coordinates place  on the screen.

Btw, nice graphic style you are creating ?

 

 

Link to comment
Share on other sites

4 minutes ago, Marcousik said:

Ok look at the function description, I think you forgot something very easy:

https://www.leadwerks.com/learn?page=API-Reference_Object_Context_DrawText

  • DrawText(string text, number x, number y, number kerning=1.0)

> The x,y are what you are seeking I suppose, coordinates place  on the screen.

Thanks for your answer.

But this ist not a working solution for me, since depending on the resolution of the game on the user's computer, those coordinates change, and text could go out of frame.

Also I need to use the WRAP option to wrap the text in several lines for long texts, with Drawtext I don't know how to control that. Based on what i know i think only LABEL has that property. But i have the same problem. If i adjust X and Y on in FULL HD using context.GetHeight() or context.GetWidth(), if I change the resolution to HD or less, the text doesn't appear in place. Appears out of frame.

Even if I don't use any frames and i leave the text free on the screen, i don't know how center down in the screen in all resolutions.

This drive me crazy. ? XD

Link to comment
Share on other sites

Here... This is my discarded code using LABEL for large subtitles with WRAP option:

Script.FuenteHud = nil

local gui = GUI:Create(context)
local base = gui:GetBase()
base:SetScript("Scripts/GUI/Label.lua")

Script.TextoSubtitulo=""--string "Texto: "

function Script:Start()
	self.enabled=false
	self.entity:Hide()
	
	self.FuenteHud = Font:Load("Fonts/monotypecursiva.ttf",14)

	x=context:GetWidth()-context:GetWidth()/2
	y=context:GetHeight()-context:GetHeight()/8
	widget = Widget:Label("",x,y,800,200,base)
end

function Script:ModificaTexto()--in
	widget = Widget:Label(""..self.TextoSubtitulo,x,y,800,200,base)
	widget:SetStyle(LABEL_BORDER + LABEL_CENTER + LABEL_MIDDLE + LABEL_WRAP)
end

function Script:LimpiaTexto()--in
	widget:Hidden()
	context:Clear()

 

And this is the result using this code:

20200922125927_1.thumb.jpg.0a117176c27166ec419b8e20f1177326.jpg

Is not a bad start, but i don't like the result, or how improve this...

At this moment, my best option is to continue using images to design the texts (5-10 kbs per image):

20200921021007_1.thumb.jpg.139747536bcc10d8be6daa89d76386ad.jpg

I know is not the best solution, but until I control by code how to place the subtitles in the designated place regardless of the resolution chosen, I will continue using this system.

Thanks for your answers team!!

Link to comment
Share on other sites

41 minutes ago, Slastraf said:

Hey, just wanted to say that game looks really cool. Did you post more about it in showcase ? 

No, I have not published anything in Showcase about FotoMuseo 3D. But thanks for letting me know.
As soon as I post the new in-game content on Steam, I'll share it there.

At the moment, i'm still working on the the new content. This will be:

  • Spanish/English - Dialog/subtitle System.
  • More secret areas.
  • One new EXPO to visit it.

Thanks for your words Slastraf!!

  • Like 2
Link to comment
Share on other sites

  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...