Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 26, 2011, 11:06:36 AM (13 years ago)
Author:
dafrick
Message:

getStaticTextWindowHeight() working again for CEGUI < 0.7

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/kicklib/data/gui/scripts/GUITools.lua

    r7964 r7965  
    4646end
    4747
    48 function getStaticTextArea(static_text)
    49     local lookAndFeel = CEGUI.WidgetLookManager:getSingleton():getWidgetLook(static_text:getLookNFeel())
    50 
    51     return lookAndFeel:getNamedArea("WithFrameTextRenderArea"):getArea():getPixelRect(static_text)
    52 end
    53 
    5448function getStaticTextWindowHeight(window)
    5549    -- Get the area the text is formatted and drawn into.
    56     local formattedArea = getStaticTextArea(window)
     50    local lookAndFeel = CEGUI.WidgetLookManager:getSingleton():getWidgetLook(window:getLookNFeel())
     51    local formattedArea = lookAndFeel:getNamedArea("WithFrameTextRenderArea"):getArea():getPixelRect(window)
    5752    -- Calculate the pixel height of the frame by subtracting the height of the area above from the total height of the window.
    5853    local frameHeight = window:getUnclippedOuterRect():getHeight() - formattedArea:getHeight()
    5954
    60     local height = math.floor(CEGUI.PropertyHelper.stringToFloat(window:getProperty("VertExtent")) + frameHeight) + 1
     55    local height = 0
     56    if orxonox.GUIManager:isCEGUIVersion7() then
     57        height = math.floor(CEGUI.PropertyHelper.stringToFloat(window:getProperty("VertExtent")) + frameHeight) + 1
     58    else
     59        local lines = window:getFont():getFormattedLineCount(window:getText(), formattedArea, CEGUI.WordWrapLeftAligned)
     60        height = lines * window:getFont():getLineSpacing() + frameHeight
     61    end
    6162    return height
    6263end
Note: See TracChangeset for help on using the changeset viewer.