Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 9, 2011, 11:27:05 AM (14 years ago)
Author:
dafrick
Message:

Merging latest changes in usability branch into tutorial branch.

Location:
code/branches/tutorial
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/tutorial

  • code/branches/tutorial/data/gui/scripts/SheetManager.lua

    r8015 r8051  
    55local activeMenuSheets = {size = 0, topSheetTuple = nil}
    66local menuSheetsRoot = guiMgr:getMenuRootWindow()
    7 local bInGameConsoleClosed = false
    87local mainMenuLoaded = false
    9 orxonox.GUIManager:subscribeEventHelper(menuSheetsRoot, "KeyDown", "keyPressed")
    10 
    11 -----------------------
    12 --- Local functions ---
    13 -----------------------
    14 
    15 local function hideCursor()
    16     if cursor:isVisible() then
    17         cursor:hide()
    18     end
    19 end
    20 
    21 local function showCursor()
    22     if not cursor:isVisible() and inputMgr:isMouseExclusive() then
    23         cursor:show()
    24     end
    25 end
    26 
     8--orxonox.GUIManager:subscribeEventHelper(menuSheetsRoot, "KeyDown", "keyPressed")
     9orxonox.GUIManager:subscribeEventHelper(menuSheetsRoot, "Sized", "windowResized")
    2710
    2811------------------------
    2912--- Global functions ---
    3013------------------------
     14
     15function hideCursor()
     16    if cursor:isVisible() then
     17        cursor:hide()
     18    end
     19end
     20
     21function showCursor()
     22    if not cursor:isVisible() and inputMgr:isMouseExclusive() then
     23        cursor:show()
     24    end
     25end
    3126
    3227-- Loads the GUI with the specified name
     
    9388        ["sheet"]          = menuSheet,
    9489        ["bHidePrevious"]  = bHidePrevious,
    95         ["bNoInput"]       = bNoInput
     90        ["bNoInput"]       = bNoInput,
     91        ["name"]           = name
    9692    }
    9793    table.insert(activeMenuSheets, sheetTuple) -- indexed array access
     
    135131    if previous and previous.pressedEnter and menuSheet:hasSelection() == false then
    136132        menuSheet:setSelectionNear(1, 1)
     133    end
     134
     135    if activeMenuSheets.size > 0 then
     136        guiMgr:guisActiveChanged(true)
    137137    end
    138138
     
    207207    end
    208208
     209    if activeMenuSheets.size == 0 then
     210        guiMgr:guisActiveChanged(false)
     211    end
     212
    209213    sheetTuple.sheet:quit()
    210214end
     
    220224    -- HUGE, very HUGE hacks!
    221225
    222     -- If the InGameConsole is active, ignore the ESC command.
    223     if bInGameConsoleClosed == true then
    224         bInGameConsoleClosed = false
    225         return
    226     end
    227 
    228     -- Count the number of sheets that don't need input till the first that does.
     226    -- Count the number of sheets that don't need input until the first that does.
    229227    local counter = noInputSheetIndex()
    230228
     
    240238end
    241239
    242 function keyPressed(e)
    243     local we = tolua.cast(e, "CEGUI::KeyEventArgs")
     240-- Function to navigate the GUI, is called by the GUIManager, whenever a relevant key is pressed.
     241-- The mode specifies the action to be taken.
     242function navigateGUI(mode)
    244243    local sheet = activeMenuSheets[activeMenuSheets.size]
    245     code = tostring(we.scancode)
    246     -- Some preprocessing
    247     if not mainMenuLoaded and not sheet.bNoInput then
    248         if code == "1" then
    249             keyESC()
    250         elseif code == "0"then
    251             orxonox.CommandExecutor:execute("openConsole")
    252         end
    253     end
    254     sheet.sheet:keyPressed()
     244    sheet.sheet:keyPressed(mode)
     245end
     246
     247function windowResized(e)
     248    for name, sheet in pairs(loadedSheets) do
     249        if orxonox.GraphicsManager:getInstance():isFullScreen() or sheet.tShowCursor == TriBool.False then
     250            inputMgr:setMouseExclusive(sheet.inputState, TriBool.True)
     251        else
     252            inputMgr:setMouseExclusive(sheet.inputState, TriBool.False)
     253        end
     254    end
     255    local sheetTuple = activeMenuSheets[activeMenuSheets.size]
     256    if sheetTuple then
     257        if orxonox.GraphicsManager:getInstance():isFullScreen() and sheetTuple.sheet.tShowCursor ~= TriBool.False then
     258            showCursor()
     259        else
     260            hideCursor()
     261        end
     262        sheetTuple.sheet:windowResized()
     263    end
    255264end
    256265
     
    279288end
    280289
    281 function inGameConsoleClosed()
    282     bInGameConsoleClosed = not bInGameConsoleClosed;
     290function getGUIFirstActive(name, bHidePrevious, bNoInput)
     291    local sheet = activeMenuSheets.topSheetTuple
     292    -- If the topmost gui sheet has the input name
     293    if sheet ~= nil and sheet.name == name then
     294        guiMgr:toggleGUIHelper(name, bHidePrevious, bNoInput, false);
     295    else
     296        guiMgr:toggleGUIHelper(name, bHidePrevious, bNoInput, true);
     297    end
    283298end
    284299
Note: See TracChangeset for help on using the changeset viewer.