Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 6699 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
RevLine 
[6621]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
[6145]8function openDecisionPopup( text, callbackPtr )
[6266]9    showGUI("DecisionPopup", false, true)
10    DecisionPopup.setCallback(callbackPtr)
[6145]11    DecisionPopup.setText(text)
[6266]12end
13
[6311]14function openInfoPopup(text, functionPtr, closeButton, arguments)
[6266]15    showGUI("InfoPopup", false, true)
[6311]16    InfoPopup.execute(functionPtr, arguments)
[6266]17    InfoPopup.setText(text)
[6283]18    InfoPopup.setCloseButton(closeButton)
[6266]19end
[6355]20
21function getMinTextSize(window)
22    local size = {}
[6387]23
[6355]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()
[6387]27
[6355]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.