Changeset 9016 for code/trunk/data/gui/scripts/MiscConfigMenu.lua
- Timestamp:
- Feb 15, 2012, 11:51:58 PM (13 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/data/gui/scripts/MiscConfigMenu.lua
r8729 r9016 11 11 P.lineHeight = 0 12 12 P.commandWidth = 0 13 P. configWidth = 013 P.editboxWidth = 0 14 14 P.resetWidth = 0 15 15 P.spaceWidth = 0 … … 36 36 table.insert(P.commandList, "ChatOverlay displayTime_") 37 37 table.insert(P.commandList, "Core bDevMode_") 38 table.insert(P.commandList, "HUDNavigation MarkerLimit_") 39 table.insert(P.commandList, "HUDNavigation showDistance") 38 40 39 41 P.nameList = {} … … 56 58 table.insert(P.nameList, "Chat: display time") 57 59 table.insert(P.nameList, "Developer's Mode") 60 table.insert(P.nameList, "Marker Limit") 61 table.insert(P.nameList, "Show Distance next to cursor") 58 62 59 63 P.linesList = {} … … 75 79 end 76 80 77 P.sampleWindow:setText("configure")78 size = getMinTextSize(P.sampleWindow)79 P.configWidth = size[2]+2080 81 81 P.sampleWindow:setText("reset") 82 82 size = getMinTextSize(P.sampleWindow) 83 83 P.resetWidth = size[2]+20 84 84 85 P.spaceWidth = math.floor(1/8*P.configWidth) 85 P.spaceWidth = 10 86 87 local pane = tolua.cast(winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigPane"), "CEGUI::ScrollablePane") 88 size = pane:getViewableArea() 89 P.editboxWidth = size:getWidth() - P.commandWidth - P.resetWidth - 5*P.spaceWidth 86 90 87 91 P.createLines() 88 92 89 93 P:setButton(1, 1, { 90 ["button"] = winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigBackButton"), 91 ["callback"] = P.MiscConfigBackButton_clicked 94 ["button"] = winMgr:getWindow("orxonox/MiscConfigMenu/CancelButton"), 95 ["callback"] = P.MiscConfigCancelButton_clicked 96 }) 97 98 P:setButton(1, 2, { 99 ["button"] = winMgr:getWindow("orxonox/MiscConfigMenu/OKButton"), 100 ["callback"] = P.MiscConfigOKButton_clicked 92 101 }) 93 102 end … … 95 104 function P.createLine(k) 96 105 local offset = 0 106 -- content window for the entire line 97 107 local line = winMgr:createWindow("DefaultWindow", "orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k) 98 108 line:setHeight(CEGUI.UDim(0, P.lineHeight)) 99 109 line:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, P.lineHeight*(k-1)))) 100 110 111 -- config name 101 112 local command = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Command") 102 113 command:setText(P.nameList[k]) … … 106 117 offset = offset + P.commandWidth + P.spaceWidth 107 118 119 -- config value (editable) 108 120 local configvalue = winMgr:createWindow("MenuWidgets/Editbox", "orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Configvalue") 109 121 configvalue:setProperty("ReadOnly", "set:False") 110 122 local value = orxonox.CommandExecutor:query("getConfig " .. P.commandList[k]) 111 123 configvalue:setText(value) 112 P.sampleWindow:setText(value) 113 local size = getMinTextSize(P.sampleWindow) 114 local configvalueWidth = 2*size[2] 115 configvalue:setSize(CEGUI.UVector2(CEGUI.UDim(0, configvalueWidth), CEGUI.UDim(0.9, 0))) 124 configvalue:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.editboxWidth), CEGUI.UDim(0.9, 0))) 116 125 configvalue:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.05, 0))) 126 -- enable the reset button if the value changed 127 orxonox.GUIManager:subscribeEventHelper(configvalue, "TextAccepted", P.name .. ".MiscConfigEditbox_textAccepted") 117 128 line:addChildWindow(configvalue) 118 offset = offset + configvalueWidth + P.spaceWidth 119 120 local config = winMgr:createWindow("MenuWidgets/Button", "orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Config") 121 config:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.configWidth), CEGUI.UDim(0.9, 0))) 122 config:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.05, 0))) 123 config:setText("configure") 124 orxonox.GUIManager:subscribeEventHelper(config, "Clicked", P.name .. ".MiscConfigConfigure_clicked") 125 line:addChildWindow(config) 126 offset = offset + P.configWidth + P.spaceWidth 127 129 offset = offset + P.editboxWidth + P.spaceWidth 130 131 -- reset button (only available when value changed) 128 132 local reset = winMgr:createWindow("MenuWidgets/Button", "orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Reset") 129 133 reset:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.resetWidth), CEGUI.UDim(0.9, 0))) 130 134 reset:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.05, 0))) 131 135 reset:setText("reset") 132 orxonox.GUIManager:subscribeEventHelper(reset, "Clicked", P.name .. ".MiscConfigReset _clicked")136 orxonox.GUIManager:subscribeEventHelper(reset, "Clicked", P.name .. ".MiscConfigResetButton_clicked") 133 137 line:addChildWindow(reset) 134 138 reset:setEnabled(false) … … 153 157 end 154 158 155 function P.MiscConfigReset_clicked(e) 159 function P.MiscConfigOKButton_clicked(e) 160 for k,v in pairs(P.commandList) do 161 -- save the changes 162 local editbox = winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Configvalue") 163 orxonox.CommandExecutor:execute("config " .. P.commandList[k] .. " " .. editbox:getText()) 164 local resetButton = winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Reset") 165 resetButton:setEnabled(false) 166 end 167 168 hideMenuSheet("MiscConfigMenu") 169 end 170 171 function P.MiscConfigCancelButton_clicked(e) 172 hideMenuSheet("MiscConfigMenu") 173 end 174 175 function P.MiscConfigEditbox_textAccepted(e) 156 176 local we = CEGUI.toWindowEventArgs(e) 157 177 local name = we.window:getName() … … 160 180 local commandNr = tonumber(match()) 161 181 162 -- TODO: Implement reset. 163 end 164 165 function P.MiscConfigConfigure_clicked(e) 182 local resetButton = winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. commandNr .. "/Reset") 183 resetButton:setEnabled(true) 184 end 185 186 function P.MiscConfigResetButton_clicked(e) 166 187 local we = CEGUI.toWindowEventArgs(e) 167 188 local name = we.window:getName() … … 170 191 local commandNr = tonumber(match()) 171 192 172 local window = winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. commandNr .. "/Configvalue") 173 174 orxonox.CommandExecutor:execute("config " .. P.commandList[commandNr] .. " " .. window:getText()) 193 -- reload the old value 194 local editbox = winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. commandNr .. "/Configvalue") 175 195 local value = orxonox.CommandExecutor:query("getConfig " .. P.commandList[commandNr]) 176 window:setText(value) 177 end 178 179 function P.MiscConfigBackButton_clicked(e) 180 hideMenuSheet("MiscConfigMenu") 196 editbox:setText(value) 197 198 we.window:setEnabled(false) 181 199 end 182 200
Note: See TracChangeset
for help on using the changeset viewer.