Advertisement
Guest User

Untitled

a guest
Jan 13th, 2019
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.66 KB | None | 0 0
  1. -- modmain.lua
  2.  
  3. local _G        = GLOBAL
  4. local GetPlayer = function() return _G.ThePlayer end
  5. local TheInput  = _G.TheInput
  6.  
  7. local DST       = _G.TheSim:GetGameID() == "DST"
  8.  
  9. local require   = _G.require
  10. local TestOptionsScreen = require("screens/testoptionsscreen")
  11.  
  12. TheInput:AddKeyDownHandler(_G.KEY_B, function()
  13.   TestOptionsScreen()
  14. end)
  15.  
  16. -- screens/testoptionsscreen.lua
  17.  
  18. local Screen = require "widgets/screen"
  19. local Button = require "widgets/button"
  20. local AnimButton = require "widgets/animbutton"
  21. local Menu = require "widgets/menu"
  22. local Text = require "widgets/text"
  23. local ImageButton = require "widgets/imagebutton"
  24. local Image = require "widgets/image"
  25. local UIAnim = require "widgets/uianim"
  26. local Widget = require "widgets/widget"
  27. local PopupDialogScreen = require "screens/popupdialog"
  28. local TEMPLATES = require "widgets/templates"
  29.  
  30. local TestOptionsScreen = Class(Screen, function(self)
  31.     Screen._ctor(self, "TestOptionsScreen")
  32.  
  33.     TheInput:ClearCachedController()
  34.  
  35.     self.active = true
  36.     SetPause(true,"pause")
  37.  
  38.     --darken everything behind the dialog
  39.     self.black = self:AddChild(ImageButton("images/global.xml", "square.tex"))
  40.     self.black.image:SetVRegPoint(ANCHOR_MIDDLE)
  41.     self.black.image:SetHRegPoint(ANCHOR_MIDDLE)
  42.     self.black.image:SetVAnchor(ANCHOR_MIDDLE)
  43.     self.black.image:SetHAnchor(ANCHOR_MIDDLE)
  44.     self.black.image:SetScaleMode(SCALEMODE_FILLSCREEN)
  45.     self.black.image:SetTint(0,0,0,0) -- invisible, but clickable!
  46.     self.black:SetOnClick(function() self:unpause() end)
  47.  
  48.     self.proot = self:AddChild(Widget("ROOT"))
  49.     self.proot:SetVAnchor(ANCHOR_MIDDLE)
  50.     self.proot:SetHAnchor(ANCHOR_MIDDLE)
  51.     self.proot:SetPosition(0,0,0)
  52.     self.proot:SetScaleMode(SCALEMODE_PROPORTIONAL)
  53.  
  54.     --throw up the background
  55.     self.bg = self.proot:AddChild(TEMPLATES.CurlyWindow(-40, 236, 0.75, 0.75, 50, -31))
  56.     self.bg:SetPosition(-5,0)
  57.     self.bg.fill = self.proot:AddChild(Image("images/fepanel_fills.xml", "panel_fill_tiny.tex"))
  58.     self.bg.fill:SetSize(295, 307)
  59.     self.bg.fill:SetPosition(2, 10)
  60.  
  61.     --title
  62.     self.title = self.proot:AddChild(Text(BUTTONFONT, 50))
  63.     self.title:SetPosition(0, 105, 0)
  64.     self.title:SetString("Title")
  65.     self.title:SetColour(0,0,0,1)
  66.  
  67.     --subtitle
  68.     self.subtitle = self.proot:AddChild(Text(NEWFONT_SMALL, 16))
  69.     self.subtitle:SetPosition(0, 75, 0)
  70.     self.subtitle:SetString("Subtitle")
  71.     self.subtitle:SetColour(0,0,0,1)
  72.  
  73.     --create the menu itself
  74.     local button_w = 160
  75.     local button_h = 45
  76.  
  77.  
  78.     local buttons = {}
  79.     table.insert(buttons, {text=STRINGS.UI.PAUSEMENU.CONTINUE, cb=function() self:unpause() end })
  80.     table.insert(buttons, {text=STRINGS.UI.PAUSEMENU.DISCONNECT, cb=function() self:unpause()   end})
  81.  
  82.     self.menu = self.proot:AddChild(Menu(buttons, -button_h, false))
  83.     self.menu:SetPosition(0, 35, 0)
  84.  
  85.     TheInputProxy:SetCursorVisible(true)
  86.     self.default_focus = self.menu
  87. end)
  88.  
  89. function TestOptionsScreen:unpause()
  90.   TheInput:CacheController()
  91.   self.active = false
  92.   TheFrontEnd:PopScreen(self)
  93.   SetPause(false)
  94.   TheWorld:PushEvent("continuefrompause")
  95. end
  96.  
  97. function TestOptionsScreen:OnControl(control, down)
  98.   if GeometricOptionsScreen._base.OnControl(self, control, down) then
  99.     return true
  100.   elseif not down and (control == CONTROL_PAUSE
  101.     or control == CONTROL_CANCEL) then
  102.     self:unpause()
  103.     return true
  104.   end
  105. end
  106.  
  107. function TestOptionsScreen:OnUpdate(dt)
  108.   if self.active then
  109.     SetPause(true)
  110.   end
  111. end
  112.  
  113. function TestOptionsScreen:OnBecomeActive()
  114.   TestOptionsScreen._base.OnBecomeActive(self)
  115.   TheFrontEnd:HideTopFade()
  116. end
  117.  
  118. return TestOptionsScreen
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement