Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/gamestates2/data/gui/scripts/GUITools.lua @ 6704

Last change on this file since 6704 was 6666, checked in by rgrieder, 14 years ago

Fixed problem that can occur when BasicGUI cannot be loaded.

  • Property svn:eol-style set to native
File size: 1.6 KB
Line 
1function createSheet(sheetName)
2    -- Create object of type BasicGUI and make it global
3    local basicGUI = require("BasicGUI")
4    if basicGUI == nil then
5        error("Loading BasicGUI.lua failed")
6    end
7    local sheet = basicGUI:new(sheetName)
8    _G[sheetName] = sheet
9    return sheet
10end
11
12function openDecisionPopup( text, callbackPtr )
13    showGUI("DecisionPopup", false, true)
14    DecisionPopup.setCallback(callbackPtr)
15    DecisionPopup.setText(text)
16end
17
18function openInfoPopup(text, functionPtr, closeButton, arguments)
19    showGUI("InfoPopup", false, true)
20    InfoPopup.execute(functionPtr, arguments)
21    InfoPopup.setText(text)
22    InfoPopup.setCloseButton(closeButton)
23end
24
25function getMinTextSize(window)
26    local size = {}
27
28    local lookAndFeel = CEGUI.WidgetLookManager:getSingleton():getWidgetLook(window:getLookNFeel())
29    local height = window:getFont():getLineSpacing() + window:getUnclippedPixelRect():getHeight() - lookAndFeel:getNamedArea("WithFrameTextRenderArea"):getArea():getPixelRect(window):getHeight()
30    local width =  window:getFont():getTextExtent(window:getText()) + window:getUnclippedPixelRect():getWidth() - lookAndFeel:getNamedArea("WithFrameTextRenderArea"):getArea():getPixelRect(window):getWidth()
31
32    table.insert(size, height)
33    table.insert(size, width)
34    return size
35end
36
37function getScrollingStepSize(window)
38    local height = window:getUnclippedPixelRect():getHeight()
39    local maxHeight = CEGUI.System:getSingleton():getGUISheet():getUnclippedPixelRect():getHeight()
40    local ratio = height/maxHeight
41    return 0.008*ratio/0.3204
42end
Note: See TracBrowser for help on using the repository browser.