Bizzi Posted May 5, 2017 Share Posted May 5, 2017 It's possible to create Popups over an Mod? For sample, i had try to create it by the sample of modwarningscreen.lua. local require = GLOBAL.require local IsServer = GLOBAL.TheNet:GetIsServer() local TheFrontEnd = GLOBAL.TheFrontEnd; print(GLOBAL); -- modimport("client/MiniMap.lua") local RulesWindow = require "screens/RulesWindow" TheFrontEnd:PushScreen(RulesWindow("TITLE", "TEXT", { {text="OK", cb = function() TheFrontEnd:PopScreen() end} })) local Screen = require "widgets/screen" local Button = require "widgets/button" local AnimButton = require "widgets/animbutton" local Menu = require "widgets/menu" local Text = require "widgets/text" local Image = require "widgets/image" local UIAnim = require "widgets/uianim" local Widget = require "widgets/widget" local RulesWindow = Class(Screen, function(self, title, text, buttons, texthalign, additionaltext, textsize) Screen._ctor(self, "RulesWindow") TheInputProxy:SetCursorVisible(true) --darken everything behind the dialog self.black = self:AddChild(Image("images/global.xml", "square.tex")) self.black:SetVRegPoint(ANCHOR_MIDDLE) self.black:SetHRegPoint(ANCHOR_MIDDLE) self.black:SetVAnchor(ANCHOR_MIDDLE) self.black:SetHAnchor(ANCHOR_MIDDLE) self.black:SetScaleMode(SCALEMODE_FILLSCREEN) self.black:SetTint(0,0,0,.8) self.root = self:AddChild(Widget("ROOT")) self.root:SetVAnchor(ANCHOR_MIDDLE) self.root:SetHAnchor(ANCHOR_MIDDLE) self.root:SetPosition(0,0,0) self.root:SetScaleMode(SCALEMODE_PROPORTIONAL) --title self.title = self.root:AddChild(Text(TITLEFONT, 50)) self.title:SetPosition(0, 170, 0) self.title:SetString(title) --text local defaulttextsize = 24 if textsize then defaulttextsize = textsize end self.text = self.root:AddChild(Text(BODYTEXTFONT, defaulttextsize)) self.text:SetVAlign(ANCHOR_TOP) if texthalign then self.text:SetHAlign(texthalign) end self.text:SetPosition(0, 40, 0) self.text:SetString(text) self.text:EnableWordWrap(true) self.text:SetRegionSize(480*2, 200) if additionaltext then self.additionaltext = self.root:AddChild(Text(BODYTEXTFONT, 24)) self.additionaltext:SetVAlign(ANCHOR_TOP) self.additionaltext:SetPosition(0, -150, 0) self.additionaltext:SetString(additionaltext) self.additionaltext:EnableWordWrap(true) self.additionaltext:SetRegionSize(480*2, 100) end self.version = self:AddChild(Text(BODYTEXTFONT, 20)) --self.version:SetHRegPoint(ANCHOR_LEFT) --self.version:SetVRegPoint(ANCHOR_BOTTOM) self.version:SetHAnchor(ANCHOR_LEFT) self.version:SetVAnchor(ANCHOR_BOTTOM) self.version:SetHAlign(ANCHOR_LEFT) self.version:SetVAlign(ANCHOR_BOTTOM) self.version:SetRegionSize(200, 40) self.version:SetPosition(110, 30, 0) self.version:SetString("Rev. "..APP_VERSION.." "..PLATFORM) if buttons then --create the menu itself local button_w = 200 local space_between = 20 local spacing = button_w + space_between self.menu = self.root:AddChild(Menu(buttons, 250, true)) self.menu:SetHRegPoint(ANCHOR_MIDDLE) self.menu:SetPosition(0, -250, 0) self.default_focus = self.menu end end) return RulesWindow This my first try with LUA. 1 Link to comment https://forums.kleientertainment.com/forums/topic/78541-create-popupwindowmodal/ Share on other sites More sharing options...
Serpens Posted May 5, 2017 Share Posted May 5, 2017 what do you want? A ingame setting screen? The "auto actions" mod has such a thing when pressing "p", maybe the code of the mod helps? Menus and such stuff are very complicated. I'm advanced at lua programming, but I think menu/gui stuff is very very hard and I'm not able to code or even understand it So I would suggest you start with something easier. Link to comment https://forums.kleientertainment.com/forums/topic/78541-create-popupwindowmodal/#findComment-918289 Share on other sites More sharing options...
Bizzi Posted May 6, 2017 Author Share Posted May 6, 2017 Thanks, but the game-scripts helping a little bit more. Here is an working example: local require = GLOBAL.require local PopupDialogScreen = require "screens/popupdialog" function CreatePopup(inst) local function onOkay() GLOBAL.TheFrontEnd:PopScreen() end GLOBAL.TheFrontEnd:PushScreen(PopupDialogScreen("Popup Title", "Popup Body", { { -- Set Text text = "OK", -- Create Callback cb = onOkay } })) end AddPlayerPostInit(CreatePopup) 1 Link to comment https://forums.kleientertainment.com/forums/topic/78541-create-popupwindowmodal/#findComment-918454 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now