Changeset 11254 for code/branches/Highscore_HS16/data/gui/scripts
- Timestamp:
- Oct 31, 2016, 3:27:31 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/Highscore_HS16/data/gui/scripts/HighscoreMenu.lua
r11245 r11254 15 15 P.resetWidth = 0 16 16 P.spaceWidth = 0 17 P.imageHeight = 50 18 P.textHeight = 30 17 19 18 20 function P.onLoad() … … 26 28 P.linesList = {} 27 29 28 --Calculate design parameters:29 P.sampleWindow = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/MiscConfigMenu/MiscConfigPane/SampleWindow")30 P.sampleWindow:setText("SampleText")31 30 32 31 -- create tabs with desired tab as argument (nil for all) 33 32 34 P.createFilterTab("Game types", "gametype")35 P.createFilterTab(" Missions", "mission")33 P.createFilterTab("Game1", "game1") 34 P.createFilterTab("Game2", "game2") 36 35 --P.createFilterTab("Minigames", "minigame") 37 36 --P.createFilterTab("Showcases", "showcase") … … 40 39 --P.createFilterTab("Show All", nil) 41 40 42 -- update description and screenshot boxes43 --P.SingleplayerSelectionChanged()44 45 local size = getMinTextSize(P.sampleWindow)46 P.lineHeight = size[1]47 48 P.playerWidth = 049 for k,v in pairs(P.scoreList) do50 P.sampleWindow:setText(P.nameList[k])51 size = getMinTextSize(P.sampleWindow)52 if size[2] > P.playerWidth then53 P.playerWidth = size[2]54 end55 end56 57 P.sampleWindow:setText("reset")58 size = getMinTextSize(P.sampleWindow)59 P.resetWidth = size[2]+2060 61 P.spaceWidth = 1062 41 63 local pane = tolua.cast(winMgr:getWindow("orxonox/HighscoreMenuPane"), "CEGUI::ScrollablePane")64 size = pane:getViewableArea()65 66 P.editboxWidth = size:getWidth() - P.playerWidth - P.resetWidth - 5*P.spaceWidth67 68 P.createLines()69 70 P:setButton(1, 1, {71 ["button"] = winMgr:getWindow("orxonox/HighscoreBackButton"),72 ["callback"] = P.HighscoreBackButton_clicked73 })74 42 end 75 43 … … 89 57 90 58 -- create new tab window with desired name 91 local default = CEGUI.toListbox(winMgr:createWindow("DefaultWindow", tabName))59 local default = (winMgr:createWindow("DefaultWindow", tabName)) 92 60 default:setText(name) 61 default:setProperty("UnifiedMaxSize", "{{1,0},{1,0}}") 62 default:setProperty("UnifiedAreaRect", "{{0,0},{0,0},{1,0},{1,0}}") 63 local pane = winMgr:createWindow("MenuWidgets/ScrollablePane", tabName .. "pane") 64 pane:setSize(CEGUI.UVector2(CEGUI.UDim(1,0),CEGUI.UDim(1,0))) 65 default:addChildWindow(pane) 66 67 68 local offset = 2 69 for k,v in pairs(P.scoreList) do 70 local line = P.createPickupEntry(tabName .. k,k,tag) 71 table.insert(P.linesList, line) 72 line:setYPosition(CEGUI.UDim(0,offset)) 73 offset = offset + line:getHeight():asAbsolute(1)+2 74 pane:addChildWindow(line) 75 end 76 93 77 94 78 local tabControl = winMgr:getWindow("orxonox/HighscoreTabControl") 95 79 orxonox.GUIManager:subscribeEventHelper(tabControl, "TabSelectionChanged", P.name..".HighscoreSelectionChanged") 96 80 --if listbox:getItemCount() > 0 then 97 tabControl:addChildWindow( tabName)81 tabControl:addChildWindow(default) 98 82 --end 99 83 100 84 101 85 end 86 function P.createPickupEntry(parent,k,tag) 87 88 local name = "orxonox/HiscoreEntry" .. parent 102 89 90 local item = winMgr:createWindow("DefaultWindow", name) 91 item:setSize(CEGUI.UVector2(CEGUI.UDim(1, 0), CEGUI.UDim(0, P.imageHeight))) 92 item:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, 0))) 93 94 local player = winMgr:createWindow("MenuWidgets/StaticText", name .. "/Player") 95 player:setText(P.nameList[k].. tag) 96 player:setPosition(CEGUI.UVector2(CEGUI.UDim(0.005,0), CEGUI.UDim(0,0))) 97 player:setSize(CEGUI.UVector2(CEGUI.UDim(0.49, 0), CEGUI.UDim(0, P.imageHeight))) 98 99 item:addChildWindow(player) 100 101 local score = winMgr:createWindow("MenuWidgets/StaticText", name .. "/Score") 102 score:setText(P.scoreList[k]) 103 score:setPosition(CEGUI.UVector2(CEGUI.UDim(0.5,0), CEGUI.UDim(0,0))) 104 score:setSize(CEGUI.UVector2(CEGUI.UDim(0.495, 0), CEGUI.UDim(0, P.imageHeight))) 105 106 item:addChildWindow(score) 107 108 return item 109 end 103 110 function P.HighscoreGetSelectedLevel() 104 111 -- choose the active listbox … … 117 124 118 125 function P.HighscoreSelectionChanged(e) 119 local pane = tolua.cast(winMgr:getWindow("orxonox/HighscoreMenuPane"), "CEGUI::ScrollablePane")120 pane:moveToFront()126 --local pane = tolua.cast(winMgr:getWindow("orxonox/HighscoreMenuPane"), "CEGUI::ScrollablePane") 127 --pane:moveToFront() 121 128 --[[local levelDescription = winMgr:getWindow("orxonox/SingleplayerLevelDescription") 122 129 local configButton = winMgr:getWindow("orxonox/SingleplayerConfigButton") … … 142 149 end 143 150 144 function P.createLine(k,tag)145 146 local tabName = k147 148 if tag ~= nil then149 tabName = tabName..tag150 end151 152 -- content window for the entire line153 local line = winMgr:createWindow("DefaultWindow", "orxonox/HighscoreMenuPane/Score" .. tabName)154 line:setHeight(CEGUI.UDim(0, P.lineHeight))155 line:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, P.lineHeight*(k-1))))156 157 local pane = tolua.cast(winMgr:getWindow("orxonox/HighscoreMenuPane"), "CEGUI::ScrollablePane")158 local half = (pane:getViewableArea()):getWidth() * 0.5159 local offset = half * 0.01160 -- config name161 local player = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/HighscoreMenuPane/Score" .. tabName .. "/Player")162 player:setText(P.nameList[k])163 player:setSize(CEGUI.UVector2(CEGUI.UDim(0, half-offset), CEGUI.UDim(1, 0)))164 player:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, 0)))165 line:addChildWindow(player)166 167 168 -- config value (editable)169 170 local playerValue = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/HighscoreMenuPane/Score" .. tabName .. "/Value")171 --playerValue:setProperty("ReadOnly", "set:False")172 --local value = orxonox.CommandExecutor:query("getConfig " .. P.commandList[k])SS173 playerValue:setText(P.scoreList[k])174 playerValue:setSize(CEGUI.UVector2(CEGUI.UDim(0, half-offset), CEGUI.UDim(1, 0)))175 playerValue:setPosition(CEGUI.UVector2(CEGUI.UDim(0, half+offset), CEGUI.UDim(0, 0)))176 -- enable the reset button if the value changed177 orxonox.GUIManager:subscribeEventHelper(playerValue, "TextAccepted", P.name .. ".MiscConfigEditbox_textAccepted")178 line:addChildWindow(playerValue)179 180 181 182 line:setWidth(CEGUI.UDim(0, 2*half))183 184 return line185 end186 187 function P.createLines()188 local window = winMgr:getWindow("orxonox/HighscoreMenuPane")189 190 for k,v in pairs(P.scoreList) do191 local line = P.createLine(k,nil)192 table.insert(P.linesList, line)193 window:addChildWindow(line)194 end195 196 local pane = tolua.cast(window, "CEGUI::ScrollablePane")197 pane:setVerticalStepSize(getScrollingStepSize(window))198 end199 200 151 201 152 function P.HighscoreBackButton_clicked(e)
Note: See TracChangeset
for help on using the changeset viewer.