Changeset 8938 for code/branches/menue
- Timestamp:
- Nov 16, 2011, 3:46:36 PM (13 years ago)
- Location:
- code/branches/menue/data/gui
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/menue/data/gui/layouts/SingleplayerConfigMenu.layout
r8927 r8938 9 9 <Property Name="BackgroundEnabled" Value="False" /> 10 10 <Window Type="MenuWidgets/StaticText" Name="orxonox/SingleplayerConfigMenu/ConfigWindow" > 11 <Property Name="Text" Value=" Miscellaneous" />11 <Property Name="Text" Value="Config" /> 12 12 <Property Name="Alpha" Value="0.8" /> 13 13 <Property Name="InheritsAlpha" Value="False" /> -
code/branches/menue/data/gui/scripts/SingleplayerConfigMenu.lua
r8927 r8938 3 3 local P = createMenuSheet("SingleplayerConfigMenu") 4 4 5 P.commandList = {} 6 P.nameList = {} 7 P.linesList = {} 8 9 P.sampleWindow = nil 10 11 P.lineHeight = 0 12 P.commandWidth = 0 13 P.editboxWidth = 0 14 P.resetWidth = 0 15 P.spaceWidth = 0 16 17 function P.onLoad() 18 P.sampleWindow = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/SingleplayerConfigMenu/MiscConfigPane/SampleWindow") 19 P.sampleWindow:setText("SampleText") 20 21 P:setButton(1, 1, { 22 ["button"] = winMgr:getWindow("orxonox/SingleplayerConfigMenu/CancelButton"), 23 ["callback"] = P.SingleplayerConfigCancelButton_clicked 24 }) 25 26 P:setButton(1, 2, { 27 ["button"] = winMgr:getWindow("orxonox/SingleplayerConfigMenu/OKButton"), 28 ["callback"] = P.SingleplayerConfigOKButton_clicked 29 }) 30 end 31 32 function P.onHide() 33 34 end 35 36 function P.loadConfig(level) 37 P.commandList = {} 38 table.insert(P.commandList, "Gametype initialStartCountdown_") 39 table.insert(P.commandList, "Gametype bAutoStart_") 40 table.insert(P.commandList, "Gametype numberOfBots_") 41 table.insert(P.commandList, "UnderAttack gameTime_") 42 table.insert(P.commandList, "TeamDeathmatch teams_") 43 44 P.nameList = {} 45 table.insert(P.nameList, "Start countdown") 46 table.insert(P.nameList, "Autostart") 47 table.insert(P.nameList, "Number of Bots") 48 table.insert(P.nameList, "UnderAttack: game time") 49 table.insert(P.nameList, "TeamDeathmatch: Number of teams") 50 51 P.linesList = {} 52 53 --Calculate design parameters: 54 local size = getMinTextSize(P.sampleWindow) 55 P.lineHeight = size[1] 56 57 P.commandWidth = 0 58 for k,v in pairs(P.commandList) do 59 P.sampleWindow:setText(P.nameList[k]) 60 size = getMinTextSize(P.sampleWindow) 61 if size[2] > P.commandWidth then 62 P.commandWidth = size[2] 63 end 64 end 65 66 P.sampleWindow:setText("reset") 67 size = getMinTextSize(P.sampleWindow) 68 P.resetWidth = size[2]+20 69 70 P.spaceWidth = 10 71 72 local pane = tolua.cast(winMgr:getWindow("orxonox/SingleplayerConfigMenu/MiscConfigPane"), "CEGUI::ScrollablePane") 73 size = pane:getViewableArea() 74 P.editboxWidth = size:getWidth() - P.commandWidth - P.resetWidth - 5*P.spaceWidth 75 76 P.createLines() 77 end 78 79 function P.createLine(k) 80 local offset = 0 81 local line = winMgr:createWindow("DefaultWindow", "orxonox/SingleplayerConfigMenu/MiscConfigPane/ConfigCommand" .. k) 82 line:setHeight(CEGUI.UDim(0, P.lineHeight)) 83 line:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, P.lineHeight*(k-1)))) 84 85 local command = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/SingleplayerConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Command") 86 command:setText(P.nameList[k]) 87 command:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.commandWidth), CEGUI.UDim(1, 0))) 88 command:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0, 0))) 89 line:addChildWindow(command) 90 offset = offset + P.commandWidth + P.spaceWidth 91 92 local configvalue = winMgr:createWindow("MenuWidgets/Editbox", "orxonox/SingleplayerConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Configvalue") 93 configvalue:setProperty("ReadOnly", "set:False") 94 local value = orxonox.CommandExecutor:query("getConfig " .. P.commandList[k]) 95 configvalue:setText(value) 96 configvalue:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.editboxWidth), CEGUI.UDim(0.9, 0))) 97 configvalue:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.05, 0))) 98 orxonox.GUIManager:subscribeEventHelper(configvalue, "TextAccepted", P.name .. ".SingleplayerConfigEditbox_textAccepted") 99 line:addChildWindow(configvalue) 100 offset = offset + P.editboxWidth + P.spaceWidth 101 102 local reset = winMgr:createWindow("MenuWidgets/Button", "orxonox/SingleplayerConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Reset") 103 reset:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.resetWidth), CEGUI.UDim(0.9, 0))) 104 reset:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.05, 0))) 105 reset:setText("reset") 106 orxonox.GUIManager:subscribeEventHelper(reset, "Clicked", P.name .. ".SingleplayerConfigResetButton_clicked") 107 line:addChildWindow(reset) 108 reset:setEnabled(false) 109 offset = offset + P.resetWidth + P.spaceWidth 110 111 line:setWidth(CEGUI.UDim(0, offset)) 112 113 return line 114 end 115 116 function P.createLines() 117 local window = winMgr:getWindow("orxonox/SingleplayerConfigMenu/MiscConfigPane") 118 119 for k,v in pairs(P.commandList) do 120 local line = P.createLine(k) 121 table.insert(P.linesList, line) 122 window:addChildWindow(line) 123 end 124 125 local pane = tolua.cast(window, "CEGUI::ScrollablePane") 126 pane:setVerticalStepSize(getScrollingStepSize(window)) 127 end 128 129 function P.SingleplayerConfigOKButton_clicked(e) 130 for k,v in pairs(P.commandList) do 131 local editbox = winMgr:getWindow("orxonox/SingleplayerConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Configvalue") 132 orxonox.CommandExecutor:execute("config " .. P.commandList[k] .. " " .. editbox:getText()) 133 local resetButton = winMgr:getWindow("orxonox/SingleplayerConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Reset") 134 resetButton:setEnabled(false) 135 end 136 137 hideMenuSheet("SingleplayerConfigMenu") 138 end 139 140 function P.SingleplayerConfigCancelButton_clicked(e) 141 hideMenuSheet("SingleplayerConfigMenu") 142 end 143 144 function P.SingleplayerConfigEditbox_textAccepted(e) 145 local we = CEGUI.toWindowEventArgs(e) 146 local name = we.window:getName() 147 148 local match = string.gmatch(name, "%d+") 149 local commandNr = tonumber(match()) 150 151 local resetButton = winMgr:getWindow("orxonox/SingleplayerConfigMenu/MiscConfigPane/ConfigCommand" .. commandNr .. "/Reset") 152 resetButton:setEnabled(true) 153 end 154 155 function P.SingleplayerConfigResetButton_clicked(e) 156 local we = CEGUI.toWindowEventArgs(e) 157 local name = we.window:getName() 158 159 local match = string.gmatch(name, "%d+") 160 local commandNr = tonumber(match()) 161 162 local editbox = winMgr:getWindow("orxonox/SingleplayerConfigMenu/MiscConfigPane/ConfigCommand" .. commandNr .. "/Configvalue") 163 local value = orxonox.CommandExecutor:query("getConfig " .. P.commandList[commandNr]) 164 editbox:setText(value) 165 166 we.window:setEnabled(false) 167 end 168 5 169 return P -
code/branches/menue/data/gui/scripts/SingleplayerMenu.lua
r8931 r8938 135 135 136 136 function P.SingleplayerConfigButton_clicked(e) 137 showMenuSheet("SingleplayerConfigMenu", true) 137 local level = P.SingleplayerGetSelectedLevel() 138 if level ~= nil then 139 local X = showMenuSheet("SingleplayerConfigMenu") 140 X:loadConfig(level) 141 end 138 142 end 139 143
Note: See TracChangeset
for help on using the changeset viewer.