-- HighscoreMenu.lua local P = createMenuSheet("HighscoreMenu") P.scrollbarWidth = 13 P.nameList = {} P.scoreList = {} P.linesList = {} P.sampleWindow = nil P.lineHeight = 0 P.playerWidth = 0 P.editboxWidth = 0 P.resetWidth = 0 P.spaceWidth = 0 function P.onLoad() P.nameList = {} table.insert(P.nameList, "firsttestPlayer") table.insert(P.nameList, "secondtestPlayer") P.scoreList = {} table.insert(P.scoreList, 120) table.insert(P.scoreList, 20) P.linesList = {} --Calculate design parameters: P.sampleWindow = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/MiscConfigMenu/MiscConfigPane/SampleWindow") P.sampleWindow:setText("SampleText") local size = getMinTextSize(P.sampleWindow) P.lineHeight = size[1] P.playerWidth = 0 for k,v in pairs(P.scoreList) do P.sampleWindow:setText(P.nameList[k]) size = getMinTextSize(P.sampleWindow) if size[2] > P.playerWidth then P.playerWidth = size[2] end end P.sampleWindow:setText("reset") size = getMinTextSize(P.sampleWindow) P.resetWidth = size[2]+20 P.spaceWidth = 10 local pane = tolua.cast(winMgr:getWindow("orxonox/HighscoreMenuPane"), "CEGUI::ScrollablePane") size = pane:getViewableArea() P.editboxWidth = size:getWidth() - P.playerWidth - P.resetWidth - 5*P.spaceWidth P.createLines() P:setButton(1, 1, { ["button"] = winMgr:getWindow("orxonox/HighscoreBackButton"), ["callback"] = P.HighscoreBackButton_clicked }) end function P.onShow() --local description = winMgr:getWindow("orxonox/HighscoreText") --height = getStaticTextWindowHeight(description) --description:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -P.scrollbarWidth), CEGUI.UDim(0.0, height))) end function P.createLine(k) -- content window for the entire line local line = winMgr:createWindow("DefaultWindow", "orxonox/HighscoreMenuPane/Score" .. k) line:setHeight(CEGUI.UDim(0, P.lineHeight)) line:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, P.lineHeight*(k-1)))) local pane = tolua.cast(winMgr:getWindow("orxonox/HighscoreMenuPane"), "CEGUI::ScrollablePane") local half = (pane:getViewableArea()):getWidth() * 0.5 local offset = half * 0.01 -- config name local player = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/HighscoreMenuPane/Score" .. k .. "/Player") player:setText(P.nameList[k]) player:setSize(CEGUI.UVector2(CEGUI.UDim(0, half-offset), CEGUI.UDim(1, 0))) player:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, 0))) line:addChildWindow(player) -- config value (editable) local playerValue = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/HighscoreMenuPane/Score" .. k .. "/Value") --playerValue:setProperty("ReadOnly", "set:False") --local value = orxonox.CommandExecutor:query("getConfig " .. P.commandList[k])SS playerValue:setText(P.scoreList[k]) playerValue:setSize(CEGUI.UVector2(CEGUI.UDim(0, half-offset), CEGUI.UDim(1, 0))) playerValue:setPosition(CEGUI.UVector2(CEGUI.UDim(0, half+offset), CEGUI.UDim(0, 0))) -- enable the reset button if the value changed orxonox.GUIManager:subscribeEventHelper(playerValue, "TextAccepted", P.name .. ".MiscConfigEditbox_textAccepted") line:addChildWindow(playerValue) line:setWidth(CEGUI.UDim(0, 2*half)) return line end function P.createLines() local window = winMgr:getWindow("orxonox/HighscoreMenuPane") for k,v in pairs(P.scoreList) do local line = P.createLine(k) table.insert(P.linesList, line) window:addChildWindow(line) end local pane = tolua.cast(window, "CEGUI::ScrollablePane") pane:setVerticalStepSize(getScrollingStepSize(window)) end function P.HighscoreBackButton_clicked(e) hideMenuSheet(P.name) end return P