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
RevLine 
[6662]1function createSheet(sheetName)
2    -- Create object of type BasicGUI and make it global
[6666]3    local basicGUI = require("BasicGUI")
4    if basicGUI == nil then
5        error("Loading BasicGUI.lua failed")
6    end
7    local sheet = basicGUI:new(sheetName)
[6662]8    _G[sheetName] = sheet
9    return sheet
10end
11
[6145]12function openDecisionPopup( text, callbackPtr )
[6266]13    showGUI("DecisionPopup", false, true)
14    DecisionPopup.setCallback(callbackPtr)
[6145]15    DecisionPopup.setText(text)
[6266]16end
17
[6311]18function openInfoPopup(text, functionPtr, closeButton, arguments)
[6266]19    showGUI("InfoPopup", false, true)
[6311]20    InfoPopup.execute(functionPtr, arguments)
[6266]21    InfoPopup.setText(text)
[6283]22    InfoPopup.setCloseButton(closeButton)
[6266]23end
[6355]24
25function getMinTextSize(window)
26    local size = {}
[6387]27
[6355]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()
[6387]31
[6355]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.