Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/hudimprovements/data/gui/scripts/GUISheet.lua @ 8740

Last change on this file since 8740 was 7689, checked in by dafrick, 14 years ago

Merging menu branch to trunk.

  • Property svn:eol-style set to native
File size: 1.4 KB
Line 
1-- GUISheet.lua
2
3local P = {}
4_G[_REQUIREDNAME or "GUISheet"] = P
5P.__index = P
6
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
12end
13
14-- Override this function if you need to do work on load
15function P:onLoad()
16end
17
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
30-- hide function for the GUI
31function P:hide()
32    self.window:hide()
33    self.bVisible = false
34
35    self:onHide()
36end
37
38-- Override this function if you need to do work on hide
39function P:onHide()
40end
41
42-- Override this function if you need to do work just after the sheet has been hidden
43function P:afterHide()
44end
45
46function P:load()
47    -- Load the layout that describes the sheet
48    self.window = winMgr:loadWindowLayout(self.name .. ".layout")
49    if self.window == nil then
50        error("Could not load layout file for GUI sheet '"..self.name.."'")
51    end
52    -- Hide it at first
53    self:hide()
54    -- Allow sheets to do some work upon loading
55    self:onLoad()
56
57    -- Also load additional sheets to avoid display lags
58    if self.loadAlong then
59        for k, sheet in pairs(self.loadAlong) do
60            loadSheet(sheet)
61        end
62    end
63    return self
64end
65
66function P:onKeyPressed(e)
67end
68
69return P
Note: See TracBrowser for help on using the repository browser.