Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 7028 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
RevLine 
[6746]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)
[6773]5    global(sheet.name)
[6746]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
[6145]17function openDecisionPopup( text, callbackPtr )
[6746]18    showMenuSheet("DecisionPopup", false, true)
[6266]19    DecisionPopup.setCallback(callbackPtr)
[6145]20    DecisionPopup.setText(text)
[6266]21end
22
[6311]23function openInfoPopup(text, functionPtr, closeButton, arguments)
[6746]24    showMenuSheet("InfoPopup", false, true)
[6311]25    InfoPopup.execute(functionPtr, arguments)
[6266]26    InfoPopup.setText(text)
[6283]27    InfoPopup.setCloseButton(closeButton)
[6266]28end
[6355]29
30function getMinTextSize(window)
31    local size = {}
[6387]32
[6355]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()
[6387]36
[6355]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.