Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 4, 2009, 1:59:39 PM (16 years ago)
Author:
scheusso
Message:

clean cursor handling in GUIManager/lua code
change in output level of lua error messages

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/ingamemenu/data/gui/scripts/InitialiseGUI.lua

    r6003 r6023  
    1414
    1515loadedGUIs = {}
    16 root = nil;
     16cursorVisibility = {}
     17activeSheets = {}
     18nrOfActiveSheets = 0
     19root = nil
     20bShowsCursor = false
    1721
    1822-- loads the GUI with the specified filename
     
    3640end
    3741
    38 function showGUI(filename, ptr)
    39     gui = showGUI(filename)
     42function showGUI(filename, bCursorVisible, ptr)
     43    gui = showGUI(filename, bCursorVisible)
    4044    gui.overlay = ptr
    4145end
     
    4347-- shows the specified and loads it if not loaded already
    4448-- be sure to set the global variable "filename" before calling this function
    45 function showGUI(filename)
     49function showGUI(filename, bCursorVisible)
     50--     bCursorVisibile=false
     51    if bCursorVisible == nil then
     52        cursorVisibility= true
     53    end
     54
    4655    if root == nil then
    4756        root = winMgr:createWindow("TaharezLook/StaticImage", "AbsoluteRootWindow")
     
    6170    root:addChildWindow(currentGUI.window)
    6271
     72    if bCursorVisible then
     73        showCursor()
     74    else
     75        hideCursor()
     76    end
     77    cursorVisibility[filename]=bCursorVisible
     78   
     79    nrOfActiveSheets = nrOfActiveSheets + 1
     80    table.insert(activeSheets, filename)
     81    activeSheets[nrOfActiveSheets] = filename
     82   
    6383    currentGUI:show()
    6484    showing = true
     
    6787
    6888function hideCursor()
    69     cursor:hide()
     89    if bShowsCursor==true then
     90        bShowsCursor=false
     91        cursor:hide()
     92    end
    7093end
    7194
    7295function showCursor()
    73     cursor:show()
     96    if bShowsCursor==false then
     97        bShowsCursor=true
     98        cursor:show()
     99    end
    74100end
    75101
    76102function hideGUI(filename)
    77103    local currentGUI = loadedGUIs[filename]
    78     if currentGUI ~= nil then
    79         currentGUI:hide()
    80         root:removeChildWindow(currentGUI.window)
    81         showing = false
     104    if currentGUI == nil then
     105        return
    82106    end
     107    currentGUI:hide()
     108    root:removeChildWindow(currentGUI.window)
     109    showing = false
     110    i=1
     111    while activeSheets[i] do
     112        if activeSheets[i+1] == nil then
     113            if activeSheets[i-1] ~= nil then
     114                if cursorVisibility[ activeSheets[i-1] ] == true then
     115                    showCursor()
     116                else
     117                    hideCursor()
     118                end
     119            else
     120                hideCursor()
     121            end
     122        end
     123        if activeSheets[i] == filename then
     124            table.remove( activeSheets, i )
     125            nrOfActiveSheets = nrOfActiveSheets-1
     126        else
     127            i = i+1
     128        end
     129    end
     130    cursorVisibility[filename] = nil -- remove the cursor visibility of the current gui from the table
    83131end
Note: See TracChangeset for help on using the changeset viewer.