Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- modmain.lua
- local _G = GLOBAL
- local GetPlayer = function() return _G.ThePlayer end
- local TheInput = _G.TheInput
- local DST = _G.TheSim:GetGameID() == "DST"
- local require = _G.require
- local TestOptionsScreen = require("screens/testoptionsscreen")
- TheInput:AddKeyDownHandler(_G.KEY_B, function()
- TestOptionsScreen()
- end)
- -- screens/testoptionsscreen.lua
- 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 ImageButton = require "widgets/imagebutton"
- local Image = require "widgets/image"
- local UIAnim = require "widgets/uianim"
- local Widget = require "widgets/widget"
- local PopupDialogScreen = require "screens/popupdialog"
- local TEMPLATES = require "widgets/templates"
- local TestOptionsScreen = Class(Screen, function(self)
- Screen._ctor(self, "TestOptionsScreen")
- TheInput:ClearCachedController()
- self.active = true
- SetPause(true,"pause")
- --darken everything behind the dialog
- self.black = self:AddChild(ImageButton("images/global.xml", "square.tex"))
- self.black.image:SetVRegPoint(ANCHOR_MIDDLE)
- self.black.image:SetHRegPoint(ANCHOR_MIDDLE)
- self.black.image:SetVAnchor(ANCHOR_MIDDLE)
- self.black.image:SetHAnchor(ANCHOR_MIDDLE)
- self.black.image:SetScaleMode(SCALEMODE_FILLSCREEN)
- self.black.image:SetTint(0,0,0,0) -- invisible, but clickable!
- self.black:SetOnClick(function() self:unpause() end)
- self.proot = self:AddChild(Widget("ROOT"))
- self.proot:SetVAnchor(ANCHOR_MIDDLE)
- self.proot:SetHAnchor(ANCHOR_MIDDLE)
- self.proot:SetPosition(0,0,0)
- self.proot:SetScaleMode(SCALEMODE_PROPORTIONAL)
- --throw up the background
- self.bg = self.proot:AddChild(TEMPLATES.CurlyWindow(-40, 236, 0.75, 0.75, 50, -31))
- self.bg:SetPosition(-5,0)
- self.bg.fill = self.proot:AddChild(Image("images/fepanel_fills.xml", "panel_fill_tiny.tex"))
- self.bg.fill:SetSize(295, 307)
- self.bg.fill:SetPosition(2, 10)
- --title
- self.title = self.proot:AddChild(Text(BUTTONFONT, 50))
- self.title:SetPosition(0, 105, 0)
- self.title:SetString("Title")
- self.title:SetColour(0,0,0,1)
- --subtitle
- self.subtitle = self.proot:AddChild(Text(NEWFONT_SMALL, 16))
- self.subtitle:SetPosition(0, 75, 0)
- self.subtitle:SetString("Subtitle")
- self.subtitle:SetColour(0,0,0,1)
- --create the menu itself
- local button_w = 160
- local button_h = 45
- local buttons = {}
- table.insert(buttons, {text=STRINGS.UI.PAUSEMENU.CONTINUE, cb=function() self:unpause() end })
- table.insert(buttons, {text=STRINGS.UI.PAUSEMENU.DISCONNECT, cb=function() self:unpause() end})
- self.menu = self.proot:AddChild(Menu(buttons, -button_h, false))
- self.menu:SetPosition(0, 35, 0)
- TheInputProxy:SetCursorVisible(true)
- self.default_focus = self.menu
- end)
- function TestOptionsScreen:unpause()
- TheInput:CacheController()
- self.active = false
- TheFrontEnd:PopScreen(self)
- SetPause(false)
- TheWorld:PushEvent("continuefrompause")
- end
- function TestOptionsScreen:OnControl(control, down)
- if GeometricOptionsScreen._base.OnControl(self, control, down) then
- return true
- elseif not down and (control == CONTROL_PAUSE
- or control == CONTROL_CANCEL) then
- self:unpause()
- return true
- end
- end
- function TestOptionsScreen:OnUpdate(dt)
- if self.active then
- SetPause(true)
- end
- end
- function TestOptionsScreen:OnBecomeActive()
- TestOptionsScreen._base.OnBecomeActive(self)
- TheFrontEnd:HideTopFade()
- end
- return TestOptionsScreen
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement