Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/gamestates3/data/gui/scripts/GUITools.lua @ 10256

Last change on this file since 10256 was 6773, checked in by rgrieder, 15 years ago

Eliminated all unnecessary global Lua variables and replaced them either with a local or a instance variable (P.myVar).

  • Property svn:eol-style set to native
File size: 1.9 KB
Line 
1-- Returns a new menu sheet
2-- See MenuSheet.new for details about the parameters
3function createMenuSheet(name, bHidePrevious, tShowCursor, tUseKeyboard, bBlockJoyStick)
4    local sheet = require("MenuSheet").new(name, bHidePrevious, tShowCursor, tUseKeyboard, bBlockJoyStick)
5    global(sheet.name)
6    _G[sheet.name] = sheet -- Global access required because of the event handlers
7    return sheet
8end
9
10-- Returns a new HUD sheet
11function createHUDSheet(name)
12    local sheet = require("HUDSheet").new(name)
13    _G[sheet.name] = sheet -- Global access required because of the event handlers
14    return sheet
15end
16
17function openDecisionPopup( text, callbackPtr )
18    showMenuSheet("DecisionPopup", false, true)
19    DecisionPopup.setCallback(callbackPtr)
20    DecisionPopup.setText(text)
21end
22
23function openInfoPopup(text, functionPtr, closeButton, arguments)
24    showMenuSheet("InfoPopup", false, true)
25    InfoPopup.execute(functionPtr, arguments)
26    InfoPopup.setText(text)
27    InfoPopup.setCloseButton(closeButton)
28end
29
30function getMinTextSize(window)
31    local size = {}
32
33    local lookAndFeel = CEGUI.WidgetLookManager:getSingleton():getWidgetLook(window:getLookNFeel())
34    local height = window:getFont():getLineSpacing() + window:getUnclippedPixelRect():getHeight() - lookAndFeel:getNamedArea("WithFrameTextRenderArea"):getArea():getPixelRect(window):getHeight()
35    local width =  window:getFont():getTextExtent(window:getText()) + window:getUnclippedPixelRect():getWidth() - lookAndFeel:getNamedArea("WithFrameTextRenderArea"):getArea():getPixelRect(window):getWidth()
36
37    table.insert(size, height)
38    table.insert(size, width)
39    return size
40end
41
42function getScrollingStepSize(window)
43    local height = window:getUnclippedPixelRect():getHeight()
44    local maxHeight = CEGUI.System:getSingleton():getGUISheet():getUnclippedPixelRect():getHeight()
45    local ratio = height/maxHeight
46    return 0.008*ratio/0.3204
47end
Note: See TracBrowser for help on using the repository browser.