Russell Posted September 19, 2020 Share Posted September 19, 2020 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!! 1 Quote Link to comment Share on other sites More sharing options...
Russell Posted September 19, 2020 Author Share Posted September 19, 2020 I'm trying do this using LABEL pressing a BUTTON. If I can do something useful and functional I will let you know. In the meantime, it would be helpful if someone gives me a clue of how make this success. Thanks a lot. Quote Link to comment Share on other sites More sharing options...
Josh Posted September 20, 2020 Share Posted September 20, 2020 What part are you having trouble with? Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Russell Posted September 20, 2020 Author Share Posted September 20, 2020 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: And this is my result using my own DESIGN of the HUD and SUBTITLES writen inside: 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. Quote Link to comment Share on other sites More sharing options...
Marcousik Posted September 21, 2020 Share Posted September 21, 2020 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. 1 Quote Link to comment Share on other sites More sharing options...
Russell Posted September 21, 2020 Author Share Posted September 21, 2020 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) 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: Or even display images in the text box like this too: 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!! Quote Link to comment Share on other sites More sharing options...
Marcousik Posted September 22, 2020 Share Posted September 22, 2020 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 ? Quote Link to comment Share on other sites More sharing options...
Russell Posted September 22, 2020 Author Share Posted September 22, 2020 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 Quote Link to comment Share on other sites More sharing options...
Russell Posted September 22, 2020 Author Share Posted September 22, 2020 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: 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): 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!! Quote Link to comment Share on other sites More sharing options...
Slastraf Posted September 25, 2020 Share Posted September 25, 2020 Hey, just wanted to say that game looks really cool. Did you post more about it in showcase ? 1 Quote Link to comment Share on other sites More sharing options...
Russell Posted September 25, 2020 Author Share Posted September 25, 2020 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!! 2 Quote Link to comment Share on other sites More sharing options...
Angelwolf Posted September 28, 2020 Share Posted September 28, 2020 I want to echo Slastraf's comment. This looks really cool and looks similar to what I was working on before Leadwerks stopped running on my system. Good luck with your project, it looks very promising! 2 Quote My Games: Nightmare Prism:::WolfTale:::Dungeon Creeper:::Despair of Ordinary Men:::Piano Simulator 2016:::House (W.I.P) Link to comment Share on other sites More sharing options...
Russell Posted September 29, 2020 Author Share Posted September 29, 2020 14 hours ago, Angelwolf said: I want to echo Slastraf's comment. This looks really cool and looks similar to what I was working on before Leadwerks stopped running on my system. Good luck with your project, it looks very promising! Many thanks Angelwolf!!! ? 1 Quote Link to comment Share on other sites More sharing options...
Russell Posted November 8, 2020 Author Share Posted November 8, 2020 @Josh is possible to close this thread? Is the third or fourth Spam attempt from new spam users here... Quote Link to comment Share on other sites More sharing options...
Josh Posted November 8, 2020 Share Posted November 8, 2020 I will force approval of all first-time posts before I start shutting down parts of the site due to cyber attacks, which is what that is. 2 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Recommended Posts
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.