Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/gamestate/data/gui/scripts/GUITools.lua @ 6698

Last change on this file since 6698 was 6621, checked in by rgrieder, 15 years ago

Simplified GUI sheet creation (first lines in the lua file) a lot by exporting it to GUITools.lua

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