Core Posted July 9, 2017 Author Share Posted July 9, 2017 Ok, I got it Thank you again @GorzenDev , @Josh and others for your help! One question remains and sorry if I'm pushing it, I really tried to solve this on my own... But where should I change font of the menu items? I allready tried to load font in main.lua World:Render, and again it almost works, but it only shows new font AFTER mouseover or mouse klick. I also tried adding Redraw() right after creating menu objects, but it strangely worked only with first menu object (Resume Game). Edit. Ok, I got it working, needed to add SetFont to World:Create() too. 2 4 Quote Link to comment Share on other sites More sharing options...
GorzenDev Posted July 9, 2017 Share Posted July 9, 2017 that looks very nice. happy to help Quote Link to comment Share on other sites More sharing options...
Josh Posted July 9, 2017 Share Posted July 9, 2017 4 hours ago, GorzenDev said: this is still a work in progress and dont mind the graphics, i used whatever images i had laying about. just wanted to show that even animated elements could be created http://www.youtube.com/watch?v=4sapsnW9O1I Awesome! Using a script for each widget was a great idea, if I do say so myself, because it allows for unlimited customization like this. 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...
GorzenDev Posted July 9, 2017 Share Posted July 9, 2017 2 minutes ago, Josh said: Awesome! Using a script for each widget was a great idea, if I do say so myself, because it allows for unlimited customization like this. i agree and love it , the only wall i had to work around whas not being able to use "CallFunction()" in lua and GetScript() doesnt return the script table. so currently the animationlogic is outside of the widget script which i love to have inside the script or some kind of Script:Update() function could also work (havent tried that yet to be honest) other then that i dont see any restrictions holding me back for now. Quote Link to comment Share on other sites More sharing options...
DooMAGE Posted August 22, 2017 Share Posted August 22, 2017 On 07/07/2017 at 7:23 PM, Josh said: OK, I will show everyone how the widgets can be modified to do anything you want. Would be great if we had an official tutorial about that, I'm trying to do the same as our friend in this thread, and I'm sure since this is an official feature others devs will have trouble to figure out how to mod or create new stuff with the new LE widget system time to time again. There is some undocumented stuff like SetObject. For example I'm trying to do something simple like change the font size of the main buttons (New Game, Options and Quit), and looks like that there is no function or parameter in the widgets to do that. https://www.leadwerks.com/learn?page=API-Reference_Object_Widget_SetString name: name of the variable to set. value: value to set. Its not enough, what are the values I can set? You use "Link" in your example (menu.lua) what are the other types? I feel so lost with this feature Quote My Leadwerks games! https://ragingmages.itch.io/ Link to comment Share on other sites More sharing options...
randomdude Posted September 7, 2017 Share Posted September 7, 2017 Hello, where do I load a map as a background for the startmenu? Quote Link to comment Share on other sites More sharing options...
GorzenDev Posted September 7, 2017 Share Posted September 7, 2017 8 hours ago, randomdude said: Hello, where do I load a map as a background for the startmenu? i assume you want a pause menu (with map already loaded). just make your background transparant so you can see the world behind it. with SetObject("backgroundcolor",Vec4(r,g,b,a)); otherwise i dont see any possibility to load the actual map as a background. you could simulate this with a simple screenshot as background. or maiby even with a render to texture. (not sure havent tried it) Quote Link to comment Share on other sites More sharing options...
DooMAGE Posted September 7, 2017 Share Posted September 7, 2017 Would be great to have a real map in the background in the start menu. I use a screenshot as background and it feels lifeless In this example I used the THUI library Quote My Leadwerks games! https://ragingmages.itch.io/ Link to comment Share on other sites More sharing options...
randomdude Posted September 8, 2017 Share Posted September 8, 2017 Oh okay thanks, I thought its a map. haha Quote Link to comment Share on other sites More sharing options...
randomdude Posted September 8, 2017 Share Posted September 8, 2017 Good news, I thought I try it anyway and it is working. Main.lua -Create a world world=World:Create() Map:Load("Maps/Start.map") local font = Font:Load("Fonts/Arial.ttf",10) context:SetFont(font) and Menu.lua elseif event.source == self.newbutton then if self.newbutton:GetText()=="NEW GAME" then world:Clear() if Map:Load("Maps/NMLVL01.map") then Okay so but how do I get rid of the Time pause in the start menu? so that the map is played? Quote Link to comment Share on other sites More sharing options...
GorzenDev Posted September 10, 2017 Share Posted September 10, 2017 On 8-9-2017 at 10:20 AM, randomdude said: Good news, I thought I try it anyway and it is working. Main.lua -Create a world world=World:Create() Map:Load("Maps/Start.map") local font = Font:Load("Fonts/Arial.ttf",10) context:SetFont(font) and Menu.lua elseif event.source == self.newbutton then if self.newbutton:GetText()=="NEW GAME" then world:Clear() if Map:Load("Maps/NMLVL01.map") then Okay so but how do I get rid of the Time pause in the start menu? so that the map is played? if i understand you correctly you want NO PAUSE when in mainmenu and PAUSE when a level is loaded? honestly you would need to edit the Menu.lua quite heavily. since the vanilla Menu.lua pauses the Time whenever it Shows (escape key pressed). you would have to do a check on Show if a New Game is not started you would not use Time:Pause() else if a New Game is started you would want to use Time:Pause(). to "hack" your way out of it you could use Time:Resume() and some point. but the best solution would still be to change your Menu.lua to support Time to play when a New Game has not started yet. Quote Link to comment Share on other sites More sharing options...
randomdude Posted September 10, 2017 Share Posted September 10, 2017 Hey man, the forumupdate delete my old post. I think this function here is the reason. gui:GetBase():SetObject("backgroundcolor",Vec4(0,0,0,0)) If commented out the screen turns grey. so if we could manipulate the size of it, it should work. Time pause is only called once in the script, if commented out you hear sound. but this other function is over it so you still have a "screenshot". Quote Link to comment Share on other sites More sharing options...
GorzenDev Posted September 10, 2017 Share Posted September 10, 2017 10 hours ago, randomdude said: Hey man, the forumupdate delete my old post. I think this function here is the reason. gui:GetBase():SetObject("backgroundcolor",Vec4(0,0,0,0)) If commented out the screen turns grey. so if we could manipulate the size of it, it should work. Time pause is only called once in the script, if commented out you hear sound. but this other function is over it so you still have a "screenshot". gui:GetBase():SetObject("backgroundcolor",Vec4(0,0,0,0)) all this does is set the backgroundcolor for the baseWidget to transparant i dont see why this would be any problem to be honest. im not sure but it almost sounds like you only see 1 frame and the context doesnt clear the previous frame. i must admit it sometimes is hard to understand what exactly is your problem. ------ after reading through a unedited Main.lua could this be giving you problems ? if gamemenu:Hidden() then --Update the app timing Time:Update() --Update the world world:Update() end Quote Link to comment Share on other sites More sharing options...
Einlander Posted September 11, 2017 Share Posted September 11, 2017 Yes that is the part that is giving you issues. --if gamemenu:Hidden() then --Update the app timing Time:Update() --Update the world world:Update() --end This would keep the game running in the background when you are in a menu. But there is a HUGE catch/problem. Any script that reads input needs to be edited to be made aware that a menu is open or to ignore input. Any script that reads or sets the mouses position or the keyboard or mouses key state will need to be edited. For example,the fpsplayer script will will move your mouse to the middle of the screen and you will not be able to select anything. So you will need to think of a way to let all scripts know that they are in a menu. Quote Link to comment Share on other sites More sharing options...
randomdude Posted September 11, 2017 Share Posted September 11, 2017 I actually have no problem, I wanted a map as a background so that I dont have to use MS Paint skills. =D --if gamemenu:Hidden() then --Update the app timing Time:Update() --Update the world world:Update() --end I put both commands into the gamemenu:show function it has the same effect as the pause.time command commented out. gui:GetBase():SetObject("backgroundcolor",Vec4(0,0,0,0)) This thing here is like a layer that lies above the actual map. but even if would work, I think thats what einlander says, it is affecting all menus so if it wouldnt stop the startmenu map it will not stop the playing maps as well what is not such a good idea. So either I need to code a only startmenu menu. or I have a broken game. so I leave it and take the "screenshot" version. I have full colours so thats fine. I could make it map look like I did this stop on purpose what looks cool than. Anyway thank you guys. Quote Link to comment Share on other sites More sharing options...
GorzenDev Posted September 11, 2017 Share Posted September 11, 2017 51 minutes ago, randomdude said: I actually have no problem, I wanted a map as a background so that I dont have to use MS Paint skills. =D --if gamemenu:Hidden() then --Update the app timing Time:Update() --Update the world world:Update() --end I put both commands into the gamemenu:show function it has the same effect as the pause.time command commented out. gui:GetBase():SetObject("backgroundcolor",Vec4(0,0,0,0)) This thing here is like a layer that lies above the actual map. but even if would work, I think thats what einlander says, it is affecting all menus so if it wouldnt stop the startmenu map it will not stop the playing maps as well what is not such a good idea. So either I need to code a only startmenu menu. or I have a broken game. so I leave it and take the "screenshot" version. I have full colours so thats fine. I could make it map look like I did this stop on purpose what looks cool than. Anyway thank you guys. just a suggestion. you could always add a check to your menu for checking if the menu is in starting positon or no game loaded/started. pseudo code would be: --Main.lua if gamemenu:Hidden() or gamemenu:IsStart() then --if gamemenu:Hidden() then --Update the app timing Time:Update() --Update the world world:Update() end --Menu.lua local GameMenu={} GameMenu.startscreen = true --default to true function GameMenu:IsStart() return self.startscreen end function GameMenu:ProcessEvent(event) if event.source == self.newbutton then if self.newbutton:GetText()=="NEW GAME" then if Map:Load("Maps/start.map") then prevmapname = "start" self.newbutton:SetText("RESUME GAME") --disable startscreen when a map is loaded self.startscreen = false end end end end Quote Link to comment Share on other sites More sharing options...
Russell Posted February 28, 2020 Share Posted February 28, 2020 I want thanks this thread!! The questions of @Core and the first answers of @GorzenDev and @Josh helped me a lot with the develop of my Main Menu in my game. After 2 days fighting with the LUA Sintax with newbie eyes finally i have reached my goal, and this thread has been the key to achieving it (Load images in the menu, configure Fonts, and the explanation of the MAIN.LUA, and more) Thanks a lot team!!! I want share you result of my work with your help (first version of the main menu): 1 Quote 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.