Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/data/gui/scripts/GUISheet.lua @ 7065

Last change on this file since 7065 was 6748, checked in by rgrieder, 15 years ago

A GUISheet can assign its field "loadAlong" any strings designating other sheets that have to be loaded as well.
Implemented this for all menus sheets as I see fit (load the whole MainMenu, but don't load MainMenu or Settings for the InGameMenu).
This is just a measure to avoid lags when clicking through the menus.

  • Property svn:eol-style set to native
File size: 1.3 KB
RevLine 
[6718]1-- GUISheet.lua
[5491]2
3local P = {}
[6718]4_G[_REQUIREDNAME or "GUISheet"] = P
5P.__index = P
[5491]6
[6718]7-- Don't use directly --> use HUDSheet.new or MenuSheet.new
8function P.new(_name)
9    local newSheet = { name = _name }
10    setmetatable(newSheet, P)
11    return newSheet
[5491]12end
13
[6718]14-- Override this function if you need to do work on load
[6720]15function P:onLoad()
[5523]16end
17
[6747]18-- show function for the GUI
19function P:show()
20    self.window:show()
21    self.bVisible = true
22
23    self:onShow()
24end
25
26-- Override this function if you need to do work on show
27function P:onShow()
28end
29
[5491]30-- hide function for the GUI
[6595]31function P:hide()
[5491]32    self.window:hide()
[6718]33    self.bVisible = false
[6747]34
35    self:onHide()
[5491]36end
37
[6747]38-- Override this function if you need to do work on hide
39function P:onHide()
[5491]40end
41
[6595]42function P:load()
[6718]43    -- Load the layout that describes the sheet
[6704]44    self.window = winMgr:loadWindowLayout(self.name .. ".layout")
[6718]45    if self.window == nil then
46        error("Could not load layout file for GUI sheet '"..self.name.."'")
47    end
48    -- Hide it at first
49    self:hide()
50    -- Allow sheets to do some work upon loading
[6720]51    self:onLoad()
[6748]52
53    -- Also load additional sheets to avoid display lags
54    if self.loadAlong then
55        for k, sheet in pairs(self.loadAlong) do
56            loadSheet(sheet)
57        end
58    end
[5559]59    return self
[5491]60end
61
[5661]62return P
Note: See TracBrowser for help on using the repository browser.