Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 16, 2010, 12:22:12 PM (14 years ago)
Author:
rgrieder
Message:

Background image of the GUI is now managed by GUIManager and kept in a very simple manner: Tell it about the image set and the image name and the it will display it in the root node.
Also split SheetManager.lua from InitialiseGUI.lua to have a separate initialisation, required by GUIManager now.
And modified GUISheet.cc/h accordingly.

File:
1 copied

Legend:

Unmodified
Added
Removed
  • code/branches/gamestates2/data/gui/scripts/SheetManager.lua

    r6722 r6737  
    1 winMgr   = CEGUI.WindowManager:getSingleton()
    2 guiMgr   = orxonox.GUIManager:getInstance()
    3 inputMgr = orxonox.InputManager:getInstance()
     1-- SheetManager.lua
    42
    5 local schemeMgr = CEGUI.SchemeManager:getSingleton()
    6 local system    = CEGUI.System:getSingleton()
    7 local cursor    = CEGUI.MouseCursor:getSingleton()
    8 
    9 -- Load all required skins
    10 schemeMgr:loadScheme("TaharezGreenLook.scheme")
    11 --schemeMgr:loadScheme("TaharezLook.scheme")
    12 --schemeMgr:loadScheme("WindowsLook.scheme")
    13 --schemeMgr:loadScheme("VanillaLook.scheme")
    14 --schemeMgr:loadScheme("SleekSpaceLook.scheme")
    15 
    16 -- Connect skin specific window types with our own window types
    17 -- By loading a different file (if there is) you can change the skin
    18 -- of the menus or the HUD independently
    19 schemeMgr:loadScheme("TaharezGreenMenuWidgets.scheme")
    20 menuImageSet = "TaharezGreenLook"
    21 schemeMgr:loadScheme("TaharezGreenHUDWidgets.scheme")
    22 hudImageSet = "TaharezGreenLook"
    23 
    24 -- Just a remaining test hack
    25 schemeMgr:loadScheme("OrxonoxGUIScheme.scheme")
    26 
    27 system:setDefaultMouseCursor(menuImageSet, "MouseArrow")
    28 system:setDefaultFont("BlueHighway-12")
    29 system:setDefaultTooltip("MenuWidgets/Tooltip")
    30 
     3local cursor = CEGUI.MouseCursor:getSingleton()
    314local loadedSheets = {}
    325local activeMenuSheets = {size = 0, topSheetTuple = nil}
    33 --activeHUDSheets  = {size = 0, topSheetTuple = nil}
    34 local root = nil
    35 
    36 -- Require all tools
    37 require("GUITools")
    38 
     6local menuSheetsRoot = guiMgr:getMenuRootWindow()
    397
    408-----------------------
     
    4210-----------------------
    4311
     12local function hideCursor()
     13    if cursor:isVisible() then
     14        cursor:hide()
     15    end
     16end
     17
     18local function showCursor()
     19    if not cursor:isVisible() and inputMgr:isMouseExclusive() then
     20        cursor:show()
     21    end
     22end
     23
     24
     25------------------------
     26--- Global functions ---
     27------------------------
     28
    4429-- Loads the GUI with the specified name
    4530-- The name corresponds to the filename of the *.lua and *.layout files
    4631-- but without the extension
    47 local function loadSheet(name)
     32function loadSheet(name)
    4833    -- Check if it has already been loaded
    4934    local sheet = loadedSheets[name]
     
    5742end
    5843
    59 local function hideCursor()
    60     if cursor:isVisible() then
    61         cursor:hide()
    62     end
    63 end
    64 
    65 local function showCursor()
    66     if not cursor:isVisible() and orxonox.InputManager:getInstance():isMouseExclusive() then
    67         cursor:show()
    68     end
    69 end
    70 
    71 
    72 ------------------------
    73 --- Global functions ---
    74 ------------------------
    75 
    7644-- ?
    7745function showMenuSheet(name, bHidePrevious, ptr)
     
    8351-- Shows the specified menu sheet and loads it if neccessary
    8452function showMenuSheet(name, bHidePrevious)
     53    if name == "" then
     54        return nil
     55    end
    8556    -- Get sheet (or load it)
    8657    local menuSheet = loadSheet(name)
    87     if not menuSheet then
    88         return nil
    89     end
    9058
    9159    -- Use sheet's value if nil was provided
     
    11785    activeMenuSheets.topSheetTuple = sheetTuple
    11886
    119     if not root then
    120         setBackground("")
    121     end
    122 
    12387    -- Add sheet to the root window
    124     root:addChildWindow(menuSheet.window)
     88    menuSheetsRoot:addChildWindow(menuSheet.window)
    12589
    12690    -- Handle input distribution
    127     orxonox.InputManager:getInstance():enterState(menuSheet.inputState)
     91    inputMgr:enterState(menuSheet.inputState)
    12892
    12993    -- Only change cursor situation if menuSheet.tShowCursor ~= TriBool.Dontcare
     
    177141
    178142    -- Remove sheet with its tuple from the table
    179     root:removeChildWindow(sheetTuple.sheet.window)
     143    menuSheetsRoot:removeChildWindow(sheetTuple.sheet.window)
    180144    table.remove(activeMenuSheets, table.findIndex(activeMenuSheets, sheetTuple))
    181145    activeMenuSheets[name] = nil
     
    184148
    185149    -- Leave the input state
    186     orxonox.InputManager:getInstance():leaveState(sheetTuple.sheet.inputState)
     150    inputMgr:leaveState(sheetTuple.sheet.inputState)
    187151   
    188152    -- CURSOR SHOWING
     
    223187end
    224188
    225 function setBackground(name)
    226     local newroot
    227     if root ~= nil then
    228         root:rename("oldRootWindow")
    229     end
    230     if name ~= "" then
    231         newroot = winMgr:loadWindowLayout(name .. ".layout")
    232         newroot:rename("AbsoluteRootWindow")
    233         system:setGUISheet(newroot)
    234     else
    235         newroot = winMgr:createWindow("DefaultWindow", "AbsoluteRootWindow")
    236         newroot:setProperty("Alpha", "0.0")
    237         newroot:setSize(CEGUI.UVector2(CEGUI.UDim(1.0,0),CEGUI.UDim(1.0,0)))
    238         system:setGUISheet(newroot)
    239     end
    240     if root ~= nil then
    241         local child
    242         while root:getChildCount()~=0 do
    243             child = root:getChildAtIdx(0)
    244             root:removeChildWindow(child)
    245             newroot:addChildWindow(child)
    246         end
    247         winMgr:destroyWindow(root)
    248     end
    249     newroot:show()
    250     root = newroot
     189function setBackgroundImage(imageSet, imageName)
     190    guiMgr:setBackgroundImage(imageSet, imageName)
    251191end
     192
     193----------------------
     194--- Initialisation ---
     195----------------------
     196
     197hideCursor()
Note: See TracChangeset for help on using the changeset viewer.