| 
                Last change
                  on this file since 8724 was
                  6748,
                  checked in by rgrieder, 16 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
           | 
      
      
        
  | Line |   | 
|---|
| 1 | -- GUISheet.lua | 
|---|
| 2 |  | 
|---|
| 3 | local P = {} | 
|---|
| 4 | _G[_REQUIREDNAME or "GUISheet"] = P | 
|---|
| 5 | P.__index = P | 
|---|
| 6 |  | 
|---|
| 7 | -- Don't use directly --> use HUDSheet.new or MenuSheet.new | 
|---|
| 8 | function P.new(_name) | 
|---|
| 9 |     local newSheet = { name = _name } | 
|---|
| 10 |     setmetatable(newSheet, P) | 
|---|
| 11 |     return newSheet | 
|---|
| 12 | end | 
|---|
| 13 |  | 
|---|
| 14 | -- Override this function if you need to do work on load | 
|---|
| 15 | function P:onLoad() | 
|---|
| 16 | end | 
|---|
| 17 |  | 
|---|
| 18 | -- show function for the GUI | 
|---|
| 19 | function P:show() | 
|---|
| 20 |     self.window:show() | 
|---|
| 21 |     self.bVisible = true | 
|---|
| 22 |  | 
|---|
| 23 |     self:onShow() | 
|---|
| 24 | end | 
|---|
| 25 |  | 
|---|
| 26 | -- Override this function if you need to do work on show | 
|---|
| 27 | function P:onShow() | 
|---|
| 28 | end | 
|---|
| 29 |  | 
|---|
| 30 | -- hide function for the GUI | 
|---|
| 31 | function P:hide() | 
|---|
| 32 |     self.window:hide() | 
|---|
| 33 |     self.bVisible = false | 
|---|
| 34 |  | 
|---|
| 35 |     self:onHide() | 
|---|
| 36 | end | 
|---|
| 37 |  | 
|---|
| 38 | -- Override this function if you need to do work on hide | 
|---|
| 39 | function P:onHide() | 
|---|
| 40 | end | 
|---|
| 41 |  | 
|---|
| 42 | function P:load() | 
|---|
| 43 |     -- Load the layout that describes the sheet | 
|---|
| 44 |     self.window = winMgr:loadWindowLayout(self.name .. ".layout") | 
|---|
| 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 | 
|---|
| 51 |     self:onLoad() | 
|---|
| 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 | 
|---|
| 59 |     return self | 
|---|
| 60 | end | 
|---|
| 61 |  | 
|---|
| 62 | return P | 
|---|
       
      
      Note: See 
TracBrowser
        for help on using the repository browser.