Changeset 7922 for code/branches/usability/data/gui/scripts
- Timestamp:
- Feb 20, 2011, 12:47:57 AM (14 years ago)
- Location:
- code/branches/usability/data/gui/scripts
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/usability/data/gui/scripts/AudioMenu.lua
r7689 r7922 2 2 3 3 local P = createMenuSheet("AudioMenu") 4 5 P.buttonList = {}6 7 function P.onShow()8 P.oldindex = -29 P.index = -110 end11 4 12 5 function P.onLoad() … … 50 43 end 51 44 52 local item = { 45 P:initButtons(1, 1) 46 P:setButton(1, 1, { 53 47 ["button"] = winMgr:getWindow("orxonox/AudioBackButton"), 54 ["function"] = P.AudioBackButton_clicked 55 } 56 P.buttonList[1] = item 48 ["callback"] = P.AudioBackButton_clicked 49 }) 57 50 end 58 51 … … 185 178 end 186 179 187 function P.onKeyPressed()188 buttonIteratorHelper(P.buttonList, code, P, 1, 1)189 end190 191 180 return P 192 181 -
code/branches/usability/data/gui/scripts/ControlsMenu.lua
r7689 r7922 2 2 3 3 local P = createMenuSheet("ControlsMenu") 4 P.buttonList = {}5 4 P.loadAlong = { "MouseControlsMenu", "KeyBindMenu" } 6 5 7 6 function P.onLoad() 8 P.multiplayerMode = "startClient" 7 P.multiplayerMode = "startClient" 9 8 10 9 --buttons are arranged in a 3x1 matrix: 11 local item = { 10 P:initButtons(3, 1) 11 12 P:setButton(1, 1, { 12 13 ["button"] = winMgr:getWindow("orxonox/MouseControlsButton"), 13 ["function"] = P.ControlsMouseControlsButton_clicked 14 } 15 P.buttonList[1] = item 14 ["callback"] = P.ControlsMouseControlsButton_clicked 15 }) 16 16 17 local item ={17 P:setButton(2, 1, { 18 18 ["button"] = winMgr:getWindow("orxonox/KeybindingsButton"), 19 ["function"] = P.ControlsKeyboardControlsButton_clicked 20 } 21 P.buttonList[2] = item 19 ["callback"] = P.ControlsKeyboardControlsButton_clicked 20 }) 22 21 23 local item ={22 P:setButton(3, 1, { 24 23 ["button"] = winMgr:getWindow("orxonox/ControlsBackButton"), 25 ["function"] = P.ControlsBackButton_clicked 26 } 27 P.buttonList[3] = item 28 29 end 30 31 function P.onShow() 32 --indices to iterate through buttonlist 33 P.oldindex = -2 34 P.index = -1 24 ["callback"] = P.ControlsBackButton_clicked 25 }) 35 26 end 36 27 … … 47 38 end 48 39 49 function P.onKeyPressed()50 buttonIteratorHelper(P.buttonList, code, P, 3, 1)51 end52 53 40 return P 54 41 -
code/branches/usability/data/gui/scripts/CreditsMenu.lua
r7732 r7922 3 3 local P = createMenuSheet("CreditsMenu") 4 4 5 P.buttonList = {}6 5 P.scrollbarWidth = 13 7 6 8 7 function P.onLoad() 9 local item = { 8 P:initButtons(1, 1) 9 P:setButton(1, 1, { 10 10 ["button"] = winMgr:getWindow("orxonox/CreditsBackButton"), 11 ["function"] = P.CreditsBackButton_clicked 12 } 13 P.buttonList[1] = item 11 ["callback"] = P.CreditsBackButton_clicked 12 }) 14 13 end 15 14 16 15 function P.onShow() 17 --indices to iterate through buttonlist18 P.oldindex = -219 P.index = -120 21 16 local description = winMgr:getWindow("orxonox/CreditsText") 22 17 description:setProperty("HorzFormatting", "WordWrapLeftAligned") … … 33 28 end 34 29 35 function P.onKeyPressed()36 buttonIteratorHelper(P.buttonList, code, P, 1, 1)37 end38 39 30 return P 40 31 -
code/branches/usability/data/gui/scripts/DecisionPopup.lua
r7726 r7922 3 3 local P = createMenuSheet("DecisionPopup") 4 4 5 P.buttonList = {}6 7 function P.onShow()8 --indices to iterate through buttonlist9 P.oldindex = -210 P.index = -111 end12 13 5 function P.onLoad() 14 6 15 7 --button are arranged in a 1x2 matrix 16 local item = { 8 P:initButtons(1, 2) 9 10 P:setButton(1, 1, { 17 11 ["button"] = winMgr:getWindow("orxonox/DecisionPopup_button_yes"), 18 ["function"] = P.button_yes 19 } 20 P.buttonList[1] = item 12 ["callback"] = P.button_yes 13 }) 21 14 22 local item ={15 P:setButton(1, 2, { 23 16 ["button"] = winMgr:getWindow("orxonox/DecisionPopup_button_no"), 24 [" function"] = P.button_no25 } 26 P.buttonList[2] = item 17 ["callback"] = P.button_no 18 }) 19 end 27 20 21 function P.onShow() 22 P:setSelection(1, 1) 28 23 end 29 24 … … 51 46 end 52 47 53 function P.onKeyPressed()54 buttonIteratorHelper(P.buttonList, code, P, 1, 2)55 end56 57 48 return P 58 49 -
code/branches/usability/data/gui/scripts/GUISheet.lua
r7689 r7922 16 16 end 17 17 18 -- Override this function if you need to do work on show 19 function P:onShow() 20 end 21 22 -- Override this function if you need to do work on hide 23 function P:onHide() 24 end 25 26 -- Override this function if you need to do work just after the sheet has been hidden 27 function P:onAfterHide() 28 end 29 18 30 -- show function for the GUI 19 31 function P:show() … … 21 33 self.bVisible = true 22 34 35 -- set the selected button's state 36 if self.buttons and self:hasSelection() then 37 self:setButtonStateSelected() 38 end 39 23 40 self:onShow() 24 end25 26 -- Override this function if you need to do work on show27 function P:onShow()28 41 end 29 42 … … 36 49 end 37 50 38 -- Override this function if you need to do work on hide39 function P:onHide()40 end41 42 -- Override this function if you need to do work just after the sheet has been hidden43 51 function P:afterHide() 52 -- reset the selected button 53 if self.buttons then 54 self:resetSelection() 55 end 56 57 self:onAfterHide() 44 58 end 45 59 … … 64 78 end 65 79 66 function P:onKeyPressed(e) 80 -- Handles key pressed while the gui sheed is displayed 81 function P:keyPressed() 82 if self.buttons then 83 if code == "208" then -- key down 84 self:moveSelection(1, 0) 85 elseif code == "200" then -- key up 86 self:moveSelection(-1, 0) 87 elseif code == "205" then -- key right 88 self:moveSelection(0, 1) 89 elseif code == "203" then -- key left 90 self:moveSelection(0, -1) 91 elseif code == "28" then -- key enter 92 self:pressSelectedButton() 93 end 94 end 95 96 self.onKeyPressed() 97 end 98 99 -- Override this function if you want to ract on keystrokes 100 function P:onKeyPressed() 101 end 102 103 104 ------------------------------------------------------------------------------- 105 -- Keyboard control ----------------------------------------------------------- 106 ------------------------------------------------------------------------------- 107 108 -- Initializes the buttons table, used to control the menu with the keyboard 109 function P:initButtons(rows, columns) 110 self.rows = rows 111 self.columns = columns 112 self.buttons = {} 113 self.selectedRow = 0 114 self.selectedColumn = 0 115 end 116 117 -- Defines the button for a given position in the table. The upper-left button is at position (1, 1) 118 function P:setButton(row, column, button) 119 assert(self.rows ~= nil and self.columns ~= nil and self.buttons ~= nil, "You have to call initButtons() before using setButton()") 120 assert(row > 0 and column > 0 and row <= self.rows and column <= self.columns, "(" .. row .. "/" .. column .. ") is not in the valid bounds of the table (1/1)-(" .. self.rows .. "/" .. self.columns .. ")") 121 122 self.buttons[(row - 1) * self.columns + (column - 1)] = button 123 end 124 125 -- Returns the button at a given position in the table. The upper-left button is at position (1, 1) 126 function P:getButton(row, column) 127 assert(row > 0 and column > 0 and row <= self.rows and column <= self.columns, "(" .. row .. "/" .. column .. ") is not in the valid bounds of the table (1/1)-(" .. self.rows .. "/" .. self.columns .. ")") 128 129 return self.buttons[(row - 1) * self.columns + (column - 1)] 130 end 131 132 -- Returns the selected button 133 function P:getSelectedButton() 134 assert(self.selectedRow > 0 and self.selectedColumn > 0, "no button selected") 135 136 return self:getButton(self.selectedRow, self.selectedColumn) 137 end 138 139 -- Presses the selected button if any 140 function P:pressSelectedButton() 141 if self:hasSelection() then 142 self:getSelectedButton().callback() 143 end 144 end 145 146 -- Sets the selection to a given row and column. The upper-left button is at position (1, 1) 147 function P:setSelection(row, column) 148 assert(row > 0 and column > 0 and row <= self.rows and column <= self.columns, "(" .. row .. "/" .. column .. ") is not in the valid bounds of the table (1/1)-(" .. self.rows .. "/" .. self.columns .. ")") 149 150 if self:hasSelection() then 151 self:setButtonStateNormal() 152 end 153 154 self.selectedRow = row 155 self.selectedColumn = column 156 157 self:setButtonStateSelected() 158 end 159 160 -- Moves the selection by a given number of rows and columns (positive values mean increasing row/column, negative values mean decreasing row/column) 161 function P:moveSelection(relRow, relColumn) 162 -- if there's no selection yet, prepare it such that the selection enters the table from the desired side 163 if self:hasSelection() == false then 164 -- note: we assume either relRow or relColumn is 0, thus no diagonal movement. therefore the following checks can be separated 165 if relRow > 0 then 166 self.selectedRow = 0 167 self.selectedColumn = 1 168 elseif relRow < 0 then 169 self.selectedRow = self.rows + 1 170 self.selectedColumn = 1 171 end 172 173 if relColumn > 0 then 174 self.selectedRow = 1 175 self.selectedColumn = 0 176 elseif relColumn < 0 then 177 self.selectedRow = 1 178 self.selectedColumn = self.columns + 1 179 end 180 else 181 self:setButtonStateNormal() 182 end 183 184 -- move the selection according to the parameters 185 self.selectedRow = self.selectedRow + relRow 186 self.selectedColumn = self.selectedColumn + relColumn 187 188 -- wrap around on overflow 189 while self.selectedRow > self.rows do 190 self.selectedRow = self.selectedRow - self.rows 191 end 192 while self.selectedColumn > self.columns do 193 self.selectedColumn = self.selectedColumn - self.columns 194 end 195 196 -- wrap around on underflow 197 while self.selectedRow <= 0 do 198 self.selectedRow = self.selectedRow + self.rows 199 end 200 while self.selectedColumn <= 0 do 201 self.selectedColumn = self.selectedColumn + self.columns 202 end 203 204 -- if the button is deactivated, call this function again 205 if self:getSelectedButton() == nil then 206 self:moveSelection(relRow, relColumn) 207 else 208 self:setButtonStateSelected() 209 end 210 end 211 212 -- Resets the selection 213 function P:resetSelection() 214 if self:hasSelection() then 215 self:setButtonStateNormal() 216 end 217 218 self.selectedRow = 0 219 self.selectedColumn = 0 220 end 221 222 -- Determines if a button is selected 223 function P:hasSelection() 224 if self.selectedRow == 0 or self.selectedColumn == 0 then 225 return false 226 else 227 return true 228 end 229 end 230 231 -- Sets the selected button's state to normal 232 function P:setButtonStateNormal() 233 self:setButtonState("Normal") 234 end 235 236 -- Sets the selected button's state to selected 237 function P:setButtonStateSelected() 238 self:setButtonState("Selected") 239 end 240 241 -- Sets the selected button's state to pushed 242 function P:setButtonStatePushed() 243 self:setButtonState("Pushed") 244 end 245 246 -- Sets the selected button's state 247 function P:setButtonState(state) 248 if self:getSelectedButton() then 249 local element = self:getSelectedButton().button 250 local offset = getElementStateOffset(element) 251 252 if offset then 253 element:setProperty("NormalImageRightEdge", string.sub(element:getProperty("NormalImageRightEdge"), 1, offset) .. state) 254 element:setProperty("NormalImageLeftEdge", string.sub(element:getProperty("NormalImageLeftEdge"), 1, offset) .. state) 255 element:setProperty("NormalImageBackground", string.sub(element:getProperty("NormalImageBackground"), 1, offset) .. state) 256 end 257 end 258 end 259 260 -- Gets the offset of the button's current state 261 function getElementStateOffset(element) 262 local property = element:getProperty("NormalImageRightEdge") 263 264 if string.sub(property, string.len(property) - 5, string.len(property)) == "Normal" then 265 return -7 266 elseif string.sub(property, string.len(property) - 7, string.len(property)) == "Selected" then 267 return -9 268 elseif string.sub(property, string.len(property) - 5, string.len(property)) == "Pushed" then 269 return -7 270 else 271 return nil 272 end 67 273 end 68 274 -
code/branches/usability/data/gui/scripts/GUITools.lua
r7913 r7922 54 54 return height 55 55 end 56 57 --function to iterate through a menu sheet by using arrowkeys58 59 --@arguments:60 -- list: 2-dimensional table, arguments are items that contain a button and its function61 -- !!note: each button can only be in the list once!!62 -- code: code of any key on the keyboard63 -- P: menusheet64 -- n: number of rows of the buttontable65 -- m: number of colums of the buttontable66 67 function buttonIteratorHelper(list, code, P, n, m)68 69 --after a key (down,up,left,right) is pressed the index of the current button has to be updated70 71 --key down72 if code == "208" then73 if P.index < 0 then -- initial status74 P.index = 075 P.oldindex = -176 else77 P.oldindex = P.index78 P.index = (P.index + m) % (m*n) --modulo operation works as a "wrap around" in the button menu79 80 while list[P.index+1] == nil do81 P.oldindex = P.index82 P.index = (P.index + m) % (m*n)83 end84 end85 86 --key up87 elseif code == "200" then88 if P.index < 0 then89 P.index = 090 P.oldindex = -191 elseif(P.index == 0) then92 P.oldindex = P.index93 P.index = m*n-m94 95 while list[P.index+1] == nil do96 P.oldindex = P.index97 P.index = (P.index-m)%(m*n)98 end99 else100 P.oldindex = P.index101 P.index = (P.index -m) % (m*n)102 103 while list[P.index+1] == nil do104 P.oldindex = P.index105 P.index = (P.index-m)%(m*n)106 end107 end108 109 --key right110 elseif code == "205" then111 if P.index < 0 then112 P.index = 0113 P.oldindex = -1114 elseif (P.index+1) % m == 0 then -- we are at the right-end of a row115 P.oldindex = P.index116 P.index = P.index + 1 -m117 118 while list[P.index+1] == nil do119 P.oldindex = P.index120 P.index = P.index + 1121 end122 else123 P.oldindex = P.index124 P.index = P.index + 1125 126 while list[P.index+1] == nil do127 if (P.index+1) % m == 0 then -- we are at the right-end of a row128 P.oldindex = P.index129 P.index = P.index + 1-m130 131 else132 P.oldindex = P.index133 P.index = P.index + 1134 end135 end136 end137 138 --key left139 elseif code == "203" then140 if P.index < 0 then141 P.index = 0142 P.oldindex = -1143 elseif P.index % m == 0 then -- we are at the left-end of a row144 P.oldindex = P.index145 P.index = P.index +m-1146 147 while list[P.index+1] == nil do148 P.oldindex = P.index149 P.index = P.index -1150 end151 else152 P.oldindex = P.index153 P.index = P.index -1154 155 while list[P.index+1] == nil do156 if P.index % m == 0 then -- we are at the left-end of a row157 P.oldindex = P.index158 P.index = P.index -1 + m159 else160 P.oldindex = P.index161 P.index = P.index -1162 end163 end164 end165 end166 167 --to update the new current button168 if (code == "208" or code == "200" or code == "203" or code == "205") and P.oldindex~= P.index then169 170 local system = CEGUI.System:getSingleton()171 local window = winMgr:getWindow("orxonox/MainMenuBackground")172 173 local item = list[P.index+1]174 local child = item["button"]175 local s = child:getProperty("NormalImageRightEdge")176 177 --teste ob der Button nicht schon gehighlightet ist178 if string.sub(s,string.len(s)-8,string.len(s)) == "Highlight" then179 --nop180 else181 child:setProperty("NormalImageRightEdge", string.sub(child:getProperty("NormalImageRightEdge"),1,-7) .. "Highlight")182 child:setProperty("NormalImageLeftEdge", string.sub(child:getProperty("NormalImageLeftEdge"),1,-7) .. "Highlight")183 child:setProperty("NormalImageBackground", string.sub(child:getProperty("NormalImageBackground"),1,-7) .. "Highlight")184 if P.oldindex >= 0 then185 if list[P.oldindex+1] ~= nil then186 local item = list[P.oldindex+1]187 local oldChild = item["button"]188 oldChild:setProperty("NormalImageRightEdge", string.sub(oldChild:getProperty("NormalImageRightEdge"),1,-10) .. "Normal")189 oldChild:setProperty("NormalImageLeftEdge", string.sub(oldChild:getProperty("NormalImageLeftEdge"),1,-10) .. "Normal")190 oldChild:setProperty("NormalImageBackground", string.sub(oldChild:getProperty("NormalImageBackground"),1,-10) .. "Normal")191 end192 end193 end194 195 --for every highlighted button check if index is on its position. If not, set imageproperty on "normal"196 local i = 1197 while i < (n*m) do198 if i == P.index +1 then199 i = i+1200 else201 if list[i] ~= nil then202 local item = list[i]203 local child = item["button"]204 local s = child:getProperty("NormalImageRightEdge")205 if string.sub(s,string.len(s)-8,string.len(s)) == "Highlight" then206 child:setProperty("NormalImageRightEdge", string.sub(child:getProperty("NormalImageRightEdge"),1,-10) .. "Normal")207 child:setProperty("NormalImageLeftEdge", string.sub(child:getProperty("NormalImageLeftEdge"),1,-10) .. "Normal")208 child:setProperty("NormalImageBackground", string.sub(child:getProperty("NormalImageBackground"),1,-10) .. "Normal")209 end210 end211 end212 i=i+1213 end214 end215 216 --enter217 if code == "28" and P.index >= 0 then218 local item = list[P.index+1]219 local child = item["button"]220 child:setProperty("NormalImageRightEdge", string.sub(child:getProperty("NormalImageRightEdge"),1,-10) .. "Normal")221 child:setProperty("NormalImageLeftEdge", string.sub(child:getProperty("NormalImageLeftEdge"),1,-10) .. "Normal")222 child:setProperty("NormalImageBackground", string.sub(child:getProperty("NormalImageBackground"),1,-10) .. "Normal")223 224 local foo = item["function"]225 foo()226 end227 228 end229 230 --write index and oldindex on the console231 --works like buttonIteratorHelper232 function indexTester(list,code,P,n,m)233 --key down234 if code == "208" then235 if P.index < 0 then -- initial status236 P.index = 0237 P.oldindex = -1238 else239 P.oldindex = P.index240 P.index = (P.index + m) % (m*n)241 242 while list[P.index+1] == nil do243 P.oldindex = P.index244 P.index = (P.index + m) % (m*n)245 end246 end247 248 --key up249 elseif code == "200" then250 if P.index < 0 then251 P.index = 0252 P.oldindex = -1253 elseif(P.index == 0) then254 P.oldindex = P.index255 P.index = m*n-m256 257 while list[P.index+1] == nil do258 P.oldindex = P.index259 P.index = (P.index-m)%(m*n)260 end261 else262 P.oldindex = P.index263 P.index = (P.index -m) % (m*n)264 265 while list[P.index+1] == nil do266 P.oldindex = P.index267 P.index = P.index -m268 end269 end270 271 --key right272 elseif code == "205" then273 if P.index < 0 then274 P.index = 0275 P.oldindex = -1276 elseif (P.index+1) % m == 0 then -- we are at the right-end of a row277 P.oldindex = P.index278 P.index = P.index + 1 -m279 280 while list[P.index+1] == nil do281 P.oldindex = P.index282 P.index = P.index + 1283 end284 else285 P.oldindex = P.index286 P.index = P.index + 1287 288 while list[P.index+1] == nil do289 if (P.index+1) % m == 0 then -- we are at the right-end of a row290 P.oldindex = P.index291 P.index = P.index + 1-m292 293 else294 P.oldindex = P.index295 P.index = P.index + 1296 end297 end298 end299 300 --key left301 elseif code == "203" then302 if P.index < 0 then303 P.index = 0304 P.oldindex = -1305 elseif P.index % m == 0 then -- we are at the left-end of a row306 P.oldindex = P.index307 P.index = P.index +m-1308 309 while list[P.index+1] == nil do310 P.oldindex = P.index311 P.index = P.index -1312 end313 else314 P.oldindex = P.index315 P.index = P.index -1316 317 while list[P.index+1] == nil do318 if P.index % m == 0 then -- we are at the left-end of a row319 P.oldindex = P.index320 P.index = P.index -1 + m321 else322 P.oldindex = P.index323 P.index = P.index -1324 end325 end326 end327 end328 329 cout(0, P.oldindex)330 cout(0, P.index)331 332 end333 334 335 336 -
code/branches/usability/data/gui/scripts/GraphicsMenu.lua
r7801 r7922 3 3 local P = createMenuSheet("GraphicsMenu") 4 4 5 P.buttonList = {}6 5 P.schemeList = {"TaharezGreen", "Orxonox"} 7 8 function P.onShow()9 --indices to iterate through buttonlist (trivial in this menu sheet)10 P.oldindex = -211 P.index = -112 end13 6 14 7 function P.onLoad() … … 93 86 block = false 94 87 95 local item = { 88 P:initButtons(1, 1) 89 P:setButton(1, 1, { 96 90 ["button"] = winMgr:getWindow("orxonox/GraphicsBackButton"), 97 ["function"] = P.GraphicsBackButton_clicked 98 } 99 P.buttonList[1] = item 91 ["callback"] = P.GraphicsBackButton_clicked 92 }) 100 93 101 94 local dropbox = winMgr:getWindow("orxonox/ThemeDropBox") … … 233 226 end 234 227 235 function P.onKeyPressed()236 buttonIteratorHelper(P.buttonList, code, P, 1, 1)237 end238 239 228 return P 240 229 -
code/branches/usability/data/gui/scripts/HostMenu.lua
r7887 r7922 5 5 P.multiplayerMode = "startServer" 6 6 7 P.buttonList = {}8 7 P.levelList = {} 9 8 P.itemList = {} … … 11 10 12 11 function P.onLoad() 13 P.multiplayerMode = "startServer" 12 P.multiplayerMode = "startServer" 14 13 local window = winMgr:getWindow("orxonox/MultiplayerShowAllCheckbox") 15 14 local button = tolua.cast(window,"CEGUI::Checkbox") … … 17 16 P.createLevelList() 18 17 19 local item = { 18 P:initButtons(1, 2) 19 20 P:setButton(1, 1, { 20 21 ["button"] = winMgr:getWindow("orxonox/HostMenuStartButton"), 21 ["function"] = P.HostMenuStartButton_clicked 22 } 23 P.buttonList[1] = item 22 ["callback"] = P.HostMenuStartButton_clicked 23 }) 24 24 25 local item ={25 P:setButton(1, 2, { 26 26 ["button"] = winMgr:getWindow("orxonox/HostMenuBackButton"), 27 ["function"] = P.HostMenuBackButton_clicked 28 } 29 P.buttonList[2] = item 27 ["callback"] = P.HostMenuBackButton_clicked 28 }) 30 29 end 31 30 … … 44 43 P.createLevelList() 45 44 end 46 47 P.oldindex = -248 P.index = -149 50 45 end 51 46 … … 97 92 end 98 93 99 function P.HostMenuStartButton_clicked(e) 94 function P.HostMenuStartButton_clicked(e) 100 95 local listbox = CEGUI.toListbox(winMgr:getWindow("orxonox/HostMenuListbox")) 101 96 local choice = listbox:getFirstSelectedItem() … … 119 114 end 120 115 121 function P.onKeyPressed()122 buttonIteratorHelper(P.buttonList, code, P, 1, 2)123 end124 125 116 return P -
code/branches/usability/data/gui/scripts/InGameMenu.lua
r7877 r7922 4 4 P.loadAlong = { "DecisionPopup" } 5 5 6 P.buttonList = {}7 8 6 function P.onLoad() 9 P.multiplayerMode = "startClient" 7 P.multiplayerMode = "startClient" 10 8 11 9 --button are arranged in a 4x1 matrix, the left lower item is nil 12 local item = { 10 P:initButtons(4, 1) 11 12 P:setButton(1, 1, { 13 13 ["button"] = winMgr:getWindow("orxonox/InGameMenu_ReturnButton"), 14 ["function"] = P.button_settings_clicked 15 } 16 P.buttonList[1] = item 14 ["callback"] = P.button_return_clicked 15 }) 17 16 18 local item ={17 P:setButton(2, 1, { 19 18 ["button"] = winMgr:getWindow("orxonox/InGameMenu_MainMenuButton"), 20 ["function"] = P.button_mainmenu_clicked 21 } 22 P.buttonList[2] = item 19 ["callback"] = P.button_mainmenu_clicked 20 }) 23 21 24 local item ={22 P:setButton(3, 1, { 25 23 ["button"] = winMgr:getWindow("orxonox/InGameMenu_SettingsButton"), 26 ["function"] = P.button_settings_clicked 27 } 28 P.buttonList[3] = item 24 ["callback"] = P.button_settings_clicked 25 }) 29 26 30 local item ={27 P:setButton(4, 1, { 31 28 ["button"] = winMgr:getWindow("orxonox/InGameMenu_QuitButton"), 32 ["function"] = P.button_quit_clicked 33 } 34 P.buttonList[4] = item 35 29 ["callback"] = P.button_quit_clicked 30 }) 36 31 end 37 32 38 33 function P.onShow() 39 --indices to iterate through buttonlist40 P.oldindex = -241 P.index = -134 if P:hasSelection() == false then 35 P:setSelection(1, 1) 36 end 42 37 end 43 38 … … 64 59 hideMenuSheet("InGameMenu") 65 60 orxonox.execute("exit") 66 else 61 else 67 62 P.onShow() 68 63 end 69 64 end 70 65 71 function P.onKeyPressed()72 buttonIteratorHelper(P.buttonList, code, P, 4, 1)73 end74 75 66 return P 76 67 -
code/branches/usability/data/gui/scripts/MainMenu.lua
r7689 r7922 4 4 P.loadAlong = { "SingleplayerMenu", "MultiplayerMenu", "SettingsMenu", "CreditsMenu" } 5 5 6 P.buttonList = {}7 8 6 function P.onLoad() 9 7 --buttons are arranged in a 6x1 Matrix (list) 10 local item = { 8 P:initButtons(6, 1) 9 10 P:setButton(1, 1, { 11 11 ["button"] = winMgr:getWindow("orxonox/QuickGameTestButton"), 12 ["function"] = P.QuickGameTestButton_clicked 13 } 14 table.insert(P.buttonList,item) 12 ["callback"] = P.QuickGameTestButton_clicked 13 }) 15 14 16 item ={15 P:setButton(2, 1, { 17 16 ["button"] = winMgr:getWindow("orxonox/SingleplayerButton"), 18 ["function"] = P.SingleplayerButton_clicked 19 } 20 table.insert(P.buttonList,item) 17 ["callback"] = P.SingleplayerButton_clicked 18 }) 21 19 22 item ={20 P:setButton(3, 1, { 23 21 ["button"] = winMgr:getWindow("orxonox/MultiplayerButton"), 24 ["function"] = P.MultiplayerButton_clicked 25 } 26 table.insert(P.buttonList,item) 22 ["callback"] = P.MultiplayerButton_clicked 23 }) 27 24 28 item ={25 P:setButton(4, 1, { 29 26 ["button"] = winMgr:getWindow("orxonox/SettingsButton"), 30 ["function"] = P.SettingsButton_clicked 31 } 32 table.insert(P.buttonList,item) 27 ["callback"] = P.SettingsButton_clicked 28 }) 33 29 34 item ={30 P:setButton(5, 1, { 35 31 ["button"] = winMgr:getWindow("orxonox/CreditsButton"), 36 ["function"] = P.CreditsButton_clicked 37 } 38 table.insert(P.buttonList,item) 32 ["callback"] = P.CreditsButton_clicked 33 }) 39 34 40 item ={35 P:setButton(6, 1, { 41 36 ["button"] = winMgr:getWindow("orxonox/ExitButton"), 42 ["function"] = P.ExitButton_clicked 43 } 44 table.insert(P.buttonList,item) 45 end 46 47 function P.onShow() 48 --indices to iterate through buttonlist 49 P.oldindex = -2 50 P.index = -1 37 ["callback"] = P.ExitButton_clicked 38 }) 51 39 end 52 40 … … 77 65 end 78 66 79 function P.onKeyPressed()80 buttonIteratorHelper(P.buttonList, code, P, 6, 1)81 end82 83 67 return P 84 68 -
code/branches/usability/data/gui/scripts/MultiplayerMenu.lua
r7916 r7922 2 2 3 3 local P = createMenuSheet("MultiplayerMenu") 4 5 P.buttonList = {}6 4 7 5 --joinMode is 1 for choice "LAN" and 2 for "Internet" … … 13 11 14 12 --button are arranged in a 2x2 matrix, the left lower item is nil 15 local item = { 13 P:initButtons(2, 2) 14 15 P:setButton(1, 1, { 16 16 ["button"] = winMgr:getWindow("orxonox/MultiplayerJoinButton"), 17 ["function"] = P.MultiplayerJoinButton_clicked 18 } 19 P.buttonList[1] = item 17 ["callback"] = P.MultiplayerJoinButton_clicked 18 }) 20 19 21 local item ={20 P:setButton(1, 2, { 22 21 ["button"] = winMgr:getWindow("orxonox/MultiplayerHostButton"), 23 ["function"] = P.MultiplayerHostButton_clicked 24 } 25 P.buttonList[2] = item 22 ["callback"] = P.MultiplayerHostButton_clicked 23 }) 26 24 27 local item ={25 P:setButton(2, 2, { 28 26 ["button"] = winMgr:getWindow("orxonox/MultiplayerBackButton"), 29 ["function"] = P.MultiplayerBackButton_clicked 30 } 31 P.buttonList[4] = item 27 ["callback"] = P.MultiplayerBackButton_clicked 28 }) 32 29 end 33 30 34 31 function P.onShow() 35 32 --P.showServerList() 36 37 --indices to iterate through buttonlist38 P.oldindex = -239 P.index = -140 33 41 34 if P.joinMode == 1 then … … 158 151 end 159 152 160 function P.onKeyPressed()161 buttonIteratorHelper(P.buttonList, code, P, 2, 2)162 end163 164 153 return P 165 154 -
code/branches/usability/data/gui/scripts/NotificationLayer.lua
r7887 r7922 46 46 end 47 47 48 -- Pushes an input notification to the input queue. 48 -- Pushes an input notification to the input queue. 49 49 function P.pushNotification(queueName, notification) 50 50 local queue = P.queueList[queueName] … … 333 333 334 334 -- Is called after the sheet has been hidden. 335 function P. afterHide()335 function P.onAfterHide() 336 336 -- If we leave the edit mode we show the sheet again. 337 337 if P.editMode then -
code/branches/usability/data/gui/scripts/SettingsMenu.lua
r7689 r7922 4 4 P.loadAlong = { "ControlsMenu", "AudioMenu", "GraphicsMenu" } 5 5 6 P.buttonList = {}7 8 6 function P.onLoad() 9 7 --"Gameplay" and "Multiplayer Options" are not integrated in the list 10 8 --buttons are arranged in a 4x2 matrix. The lower-right element is not in the matrix! 11 local item = { 9 P:initButtons(4, 2) 10 11 P:setButton(1, 2, { 12 12 ["button"] = winMgr:getWindow("orxonox/SettingsMenu/GraphicsButton"), 13 ["function"] = P.SettingsGraphicsButton_clicked 14 } 15 P.buttonList[2] = item 13 ["callback"] = P.SettingsGraphicsButton_clicked 14 }) 16 15 17 local item ={16 P:setButton(2, 2, { 18 17 ["button"] = winMgr:getWindow("orxonox/SettingsMenu/AudioButton"), 19 ["function"] = P.SettingsAudioButton_clicked 20 } 21 P.buttonList[4] = item 18 ["callback"] = P.SettingsAudioButton_clicked 19 }) 22 20 21 P:setButton(3, 1, { 22 ["button"] = winMgr:getWindow("orxonox/SettingsMenu/ControlsButton"), 23 ["callback"] = P.SettingsControlsButton_clicked 24 }) 23 25 24 local item = { 25 ["button"] = winMgr:getWindow("orxonox/SettingsMenu/ControlsButton"), 26 ["function"] = P.SettingsControlsButton_clicked 27 } 28 P.buttonList[5] = item 26 P:setButton(3, 2, { 27 ["button"] = winMgr:getWindow("orxonox/SettingsMenu/MiscellaneousButton"), 28 ["callback"] = P.SettingsMiscellaneousButton_clicked 29 }) 29 30 30 local item = { 31 ["button"] = winMgr:getWindow("orxonox/SettingsMenu/MiscellaneousButton"), 32 ["function"] = P.SettingsMiscellaneousButton_clicked 33 } 34 P.buttonList[6] = item 35 36 local item = { 31 P:setButton(4, 1, { 37 32 ["button"] = winMgr:getWindow("orxonox/SettingsMenu/SettingsBackButton"), 38 ["function"] = P.SettingsBackButton_clicked 39 } 40 P.buttonList[7] = item 41 42 end 43 44 function P.onShow() 45 --indices to iterate through buttonlist 46 P.oldindex = 3 47 P.index = 2 33 ["callback"] = P.SettingsBackButton_clicked 34 }) 48 35 end 49 36 … … 76 63 end 77 64 78 function P.onKeyPressed()79 buttonIteratorHelper(P.buttonList, code, P, 4, 2)80 end81 82 65 return P 83 66 -
code/branches/usability/data/gui/scripts/SheetManager.lua
r7689 r7922 126 126 end 127 127 end 128 128 129 129 menuSheet:show() 130 130 menuSheetsRoot:activate() … … 179 179 inputMgr:leaveState(sheetTuple.sheet.inputState) 180 180 end 181 181 182 182 -- CURSOR SHOWING 183 183 local i = activeMenuSheets.size … … 245 245 end 246 246 end 247 sheet.sheet: onKeyPressed()247 sheet.sheet:keyPressed() 248 248 end 249 249 -
code/branches/usability/data/gui/scripts/SingleplayerMenu.lua
r7876 r7922 3 3 local P = createMenuSheet("SingleplayerMenu") 4 4 5 P.buttonList = {}6 5 P.levelList = {} 7 6 P.itemList = {} … … 15 14 16 15 --buttons are arranged in a 1x2 matrix 17 local item = { 16 P:initButtons(1, 2) 17 18 P:setButton(1, 1, { 18 19 ["button"] = winMgr:getWindow("orxonox/SingleplayerStartButton"), 19 ["function"] = P.SingleplayerStartButton_clicked 20 } 21 P.buttonList[1] = item 20 ["callback"] = P.SingleplayerStartButton_clicked 21 }) 22 22 23 local item ={23 P:setButton(1, 2, { 24 24 ["button"] = winMgr:getWindow("orxonox/SingleplayerBackButton"), 25 ["function"] = P.SingleplayerBackButton_clicked 26 } 27 P.buttonList[2] = item 25 ["callback"] = P.SingleplayerBackButton_clicked 26 }) 28 27 end 29 28 … … 61 60 end 62 61 63 function P.onShow()64 --indices to iterate through buttonlist65 P.oldindex = -266 P.index = -167 end68 69 62 function P.SingleplayerStartButton_clicked(e) 70 63 local listbox = CEGUI.toListbox(winMgr:getWindow("orxonox/SingleplayerLevelListbox")) … … 93 86 end 94 87 95 function P.onKeyPressed()96 buttonIteratorHelper(P.buttonList, code, P, 1, 2)97 end98 99 88 return P 100 89
Note: See TracChangeset
for help on using the changeset viewer.