fovov
09-09-2008 09:58:20
why not use script in mygui . for example: tolua++
who could have add scrpit in mygui?
this is lua scrpit.
function sliderHandler(args)
CEGUI.System:getSingleton():getGUISheet():setAlpha(CEGUI.toSlider(CEGUI.toWindowEventArgs(args).window):getCurrentValue())
end
function panelSlideHandler(args)
local scroller = CEGUI.toScrollbar(CEGUI.toWindowEventArgs(args).window)
local demoWnd = CEGUI.WindowManager:getSingleton():getWindow("Demo8")
local relHeight = demoWnd:getHeight():asRelative(demoWnd:getParentPixelHeight())
scroller:setPosition(CEGUI.UVector2(CEGUI.UDim(0,0), CEGUI.UDim(scroller:getScrollPosition() / relHeight,0)))
demoWnd:setPosition(CEGUI.UVector2(CEGUI.UDim(0,0), CEGUI.UDim(-scroller:getScrollPosition(),0)))
end
function colourChangeHandler(args)
local winMgr = CEGUI.WindowManager:getSingleton()
local r = CEGUI.toScrollbar(winMgr:getWindow("Demo8/Window1/Controls/Red")):getScrollPosition()
local g = CEGUI.toScrollbar(winMgr:getWindow("Demo8/Window1/Controls/Green")):getScrollPosition()
local b = CEGUI.toScrollbar(winMgr:getWindow("Demo8/Window1/Controls/Blue")):getScrollPosition()
local col = CEGUI.colour:new_local(r, g, b, 1)
local crect = CEGUI.ColourRect(col)
winMgr:getWindow("Demo8/Window1/Controls/ColourSample"):setProperty("ImageColours", CEGUI.PropertyHelper:colourRectToString(crect))
end
function addItemHandler(args)
local winMgr = CEGUI.WindowManager:getSingleton()
local text = winMgr:getWindow("Demo8/Window1/Controls/Editbox"):getText()
local cols = CEGUI.PropertyHelper:stringToColourRect(winMgr:getWindow("Demo8/Window1/Controls/ColourSample"):getProperty("ImageColours"))
local newItem = CEGUI.createListboxTextItem(text, 0, nil, false, true)
newItem:setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush")
newItem:setSelectionColours(cols)
CEGUI.toListbox(winMgr:getWindow("Demo8/Window1/Listbox")):addItem(newItem)
end
local guiSystem = CEGUI.System:getSingleton()
local schemeMgr = CEGUI.SchemeManager:getSingleton()
local winMgr = CEGUI.WindowManager:getSingleton()
-- load our demo8 scheme
schemeMgr:loadScheme("Demo8.scheme");
-- load our demo8 window layout
local root = winMgr:loadWindowLayout("Demo8.layout")
-- set the layout as the root
guiSystem:setGUISheet(root)
-- set default mouse cursor
guiSystem:setDefaultMouseCursor("TaharezLook", "MouseArrow")
-- set the Tooltip type
guiSystem:setDefaultTooltip("TaharezLook/Tooltip")
-- subscribe required events
winMgr:getWindow("Demo8/ViewScroll"):subscribeEvent("ScrollPosChanged", "panelSlideHandler")
winMgr:getWindow("Demo8/Window1/Controls/Blue"):subscribeEvent("ScrollPosChanged", "colourChangeHandler")
winMgr:getWindow("Demo8/Window1/Controls/Red"):subscribeEvent("ScrollPosChanged", "colourChangeHandler")
winMgr:getWindow("Demo8/Window1/Controls/Green"):subscribeEvent("ScrollPosChanged", "colourChangeHandler")
winMgr:getWindow("Demo8/Window1/Controls/Add"):subscribeEvent("Clicked", "addItemHandler")
who could have add scrpit in mygui?
this is lua scrpit.
function sliderHandler(args)
CEGUI.System:getSingleton():getGUISheet():setAlpha(CEGUI.toSlider(CEGUI.toWindowEventArgs(args).window):getCurrentValue())
end
function panelSlideHandler(args)
local scroller = CEGUI.toScrollbar(CEGUI.toWindowEventArgs(args).window)
local demoWnd = CEGUI.WindowManager:getSingleton():getWindow("Demo8")
local relHeight = demoWnd:getHeight():asRelative(demoWnd:getParentPixelHeight())
scroller:setPosition(CEGUI.UVector2(CEGUI.UDim(0,0), CEGUI.UDim(scroller:getScrollPosition() / relHeight,0)))
demoWnd:setPosition(CEGUI.UVector2(CEGUI.UDim(0,0), CEGUI.UDim(-scroller:getScrollPosition(),0)))
end
function colourChangeHandler(args)
local winMgr = CEGUI.WindowManager:getSingleton()
local r = CEGUI.toScrollbar(winMgr:getWindow("Demo8/Window1/Controls/Red")):getScrollPosition()
local g = CEGUI.toScrollbar(winMgr:getWindow("Demo8/Window1/Controls/Green")):getScrollPosition()
local b = CEGUI.toScrollbar(winMgr:getWindow("Demo8/Window1/Controls/Blue")):getScrollPosition()
local col = CEGUI.colour:new_local(r, g, b, 1)
local crect = CEGUI.ColourRect(col)
winMgr:getWindow("Demo8/Window1/Controls/ColourSample"):setProperty("ImageColours", CEGUI.PropertyHelper:colourRectToString(crect))
end
function addItemHandler(args)
local winMgr = CEGUI.WindowManager:getSingleton()
local text = winMgr:getWindow("Demo8/Window1/Controls/Editbox"):getText()
local cols = CEGUI.PropertyHelper:stringToColourRect(winMgr:getWindow("Demo8/Window1/Controls/ColourSample"):getProperty("ImageColours"))
local newItem = CEGUI.createListboxTextItem(text, 0, nil, false, true)
newItem:setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush")
newItem:setSelectionColours(cols)
CEGUI.toListbox(winMgr:getWindow("Demo8/Window1/Listbox")):addItem(newItem)
end
local guiSystem = CEGUI.System:getSingleton()
local schemeMgr = CEGUI.SchemeManager:getSingleton()
local winMgr = CEGUI.WindowManager:getSingleton()
-- load our demo8 scheme
schemeMgr:loadScheme("Demo8.scheme");
-- load our demo8 window layout
local root = winMgr:loadWindowLayout("Demo8.layout")
-- set the layout as the root
guiSystem:setGUISheet(root)
-- set default mouse cursor
guiSystem:setDefaultMouseCursor("TaharezLook", "MouseArrow")
-- set the Tooltip type
guiSystem:setDefaultTooltip("TaharezLook/Tooltip")
-- subscribe required events
winMgr:getWindow("Demo8/ViewScroll"):subscribeEvent("ScrollPosChanged", "panelSlideHandler")
winMgr:getWindow("Demo8/Window1/Controls/Blue"):subscribeEvent("ScrollPosChanged", "colourChangeHandler")
winMgr:getWindow("Demo8/Window1/Controls/Red"):subscribeEvent("ScrollPosChanged", "colourChangeHandler")
winMgr:getWindow("Demo8/Window1/Controls/Green"):subscribeEvent("ScrollPosChanged", "colourChangeHandler")
winMgr:getWindow("Demo8/Window1/Controls/Add"):subscribeEvent("Clicked", "addItemHandler")