Changeset 8964 for code/branches
- Timestamp:
- Dec 7, 2011, 3:22:46 PM (13 years ago)
- Location:
- code/branches/menue/data/gui
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/menue/data/gui/layouts/MiscConfigMenu.layout
r7888 r8964 2 2 3 3 <GUILayout > 4 <Window Type="DefaultWindow" Name="orxonox/MiscConfigMenu/Background" > 4 <Window Type="MenuWidgets/StaticImage" Name="orxonox/MiscConfigMenu/Background" > 5 <Property Name="FrameEnabled" Value="False" /> 5 6 <Property Name="InheritsAlpha" Value="False" /> 6 7 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" /> 7 8 <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" /> 9 <Property Name="BackgroundEnabled" Value="False" /> 8 10 <Window Type="MenuWidgets/StaticText" Name="orxonox/MicsConfigMenu/ConfigWindow" > 9 11 <Property Name="Text" Value="Miscellaneous" /> … … 34 36 </Window> 35 37 </Window> 36 <Window Type="MenuWidgets/Button" Name="orxonox/MiscConfigMenu/ MiscConfigBackButton" >37 <Property Name="Text" Value=" Back" />38 <Window Type="MenuWidgets/Button" Name="orxonox/MiscConfigMenu/CancelButton" > 39 <Property Name="Text" Value="Cancel" /> 38 40 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" /> 39 <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.6625,0},{0.6,0},{0.7125,0}}" /> 40 <Event Name="Clicked" Function="MiscConfigMenu.MiscConfigBackButton_clicked"/> 41 <Property Name="UnifiedAreaRect" Value="{{0.25,0},{0.725,0},{0.4,0},{0.775,0}}" /> 42 <Event Name="Clicked" Function="MiscConfigMenu.MiscConfigCancelButton_clicked"/> 43 </Window> 44 <Window Type="MenuWidgets/Button" Name="orxonox/MiscConfigMenu/OKButton" > 45 <Property Name="Text" Value="OK" /> 46 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" /> 47 <Property Name="UnifiedAreaRect" Value="{{0.6,0},{0.725,0},{0.75,0},{0.775,0}}" /> 48 <Event Name="Clicked" Function="MiscConfigMenu.MiscConfigOKButton_clicked"/> 41 49 </Window> 42 50 </Window> -
code/branches/menue/data/gui/scripts/MiscConfigMenu.lua
r8729 r8964 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 … … 75 75 end 76 76 77 P.sampleWindow:setText("configure")78 size = getMinTextSize(P.sampleWindow)79 P.configWidth = size[2]+2080 81 77 P.sampleWindow:setText("reset") 82 78 size = getMinTextSize(P.sampleWindow) 83 79 P.resetWidth = size[2]+20 84 80 85 P.spaceWidth = math.floor(1/8*P.configWidth) 81 P.spaceWidth = 10 82 83 local pane = tolua.cast(winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigPane"), "CEGUI::ScrollablePane") 84 size = pane:getViewableArea() 85 P.editboxWidth = size:getWidth() - P.commandWidth - P.resetWidth - 5*P.spaceWidth 86 86 87 87 P.createLines() 88 88 89 89 P:setButton(1, 1, { 90 ["button"] = winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigBackButton"), 91 ["callback"] = P.MiscConfigBackButton_clicked 90 ["button"] = winMgr:getWindow("orxonox/MiscConfigMenu/CancelButton"), 91 ["callback"] = P.MiscConfigCancelButton_clicked 92 }) 93 94 P:setButton(1, 2, { 95 ["button"] = winMgr:getWindow("orxonox/MiscConfigMenu/OKButton"), 96 ["callback"] = P.MiscConfigOKButton_clicked 92 97 }) 93 98 end … … 95 100 function P.createLine(k) 96 101 local offset = 0 102 -- content window for the entire line 97 103 local line = winMgr:createWindow("DefaultWindow", "orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k) 98 104 line:setHeight(CEGUI.UDim(0, P.lineHeight)) 99 105 line:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, P.lineHeight*(k-1)))) 100 106 107 -- config name 101 108 local command = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Command") 102 109 command:setText(P.nameList[k]) … … 106 113 offset = offset + P.commandWidth + P.spaceWidth 107 114 115 -- config value (editable) 108 116 local configvalue = winMgr:createWindow("MenuWidgets/Editbox", "orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Configvalue") 109 117 configvalue:setProperty("ReadOnly", "set:False") 110 118 local value = orxonox.CommandExecutor:query("getConfig " .. P.commandList[k]) 111 119 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))) 120 configvalue:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.editboxWidth), CEGUI.UDim(0.9, 0))) 116 121 configvalue:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.05, 0))) 122 -- enable the reset button if the value changed 123 orxonox.GUIManager:subscribeEventHelper(configvalue, "TextAccepted", P.name .. ".MiscConfigEditbox_textAccepted") 117 124 line:addChildWindow(configvalue) 118 offset = offset + configvalueWidth + P.spaceWidth125 offset = offset + P.editboxWidth + P.spaceWidth 119 126 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 127 -- reset button (only available when value changed) 128 128 local reset = winMgr:createWindow("MenuWidgets/Button", "orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Reset") 129 129 reset:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.resetWidth), CEGUI.UDim(0.9, 0))) 130 130 reset:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.05, 0))) 131 131 reset:setText("reset") 132 orxonox.GUIManager:subscribeEventHelper(reset, "Clicked", P.name .. ".MiscConfigReset _clicked")132 orxonox.GUIManager:subscribeEventHelper(reset, "Clicked", P.name .. ".MiscConfigResetButton_clicked") 133 133 line:addChildWindow(reset) 134 134 reset:setEnabled(false) … … 153 153 end 154 154 155 function P.MiscConfigReset_clicked(e) 155 function P.MiscConfigOKButton_clicked(e) 156 for k,v in pairs(P.commandList) do 157 -- save the changes 158 local editbox = winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Configvalue") 159 orxonox.CommandExecutor:execute("config " .. P.commandList[k] .. " " .. editbox:getText()) 160 local resetButton = winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Reset") 161 resetButton:setEnabled(false) 162 end 163 164 hideMenuSheet("MiscConfigMenu") 165 end 166 167 function P.MiscConfigCancelButton_clicked(e) 168 hideMenuSheet("MiscConfigMenu") 169 end 170 171 function P.MiscConfigEditbox_textAccepted(e) 156 172 local we = CEGUI.toWindowEventArgs(e) 157 173 local name = we.window:getName() … … 160 176 local commandNr = tonumber(match()) 161 177 162 -- TODO: Implement reset. 178 local resetButton = winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. commandNr .. "/Reset") 179 resetButton:setEnabled(true) 163 180 end 164 181 165 function P.MiscConfig Configure_clicked(e)182 function P.MiscConfigResetButton_clicked(e) 166 183 local we = CEGUI.toWindowEventArgs(e) 167 184 local name = we.window:getName() … … 170 187 local commandNr = tonumber(match()) 171 188 172 local window = winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. commandNr .. "/Configvalue") 173 174 orxonox.CommandExecutor:execute("config " .. P.commandList[commandNr] .. " " .. window:getText()) 189 -- reload the old value 190 local editbox = winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. commandNr .. "/Configvalue") 175 191 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") 192 editbox:setText(value) 193 194 we.window:setEnabled(false) 181 195 end 182 196 -
code/branches/menue/data/gui/scripts/SingleplayerConfigMenu.lua
r8945 r8964 28 28 ["callback"] = P.SingleplayerConfigOKButton_clicked 29 29 }) 30 end31 32 function P.onHide()33 34 30 end 35 31 … … 101 97 function P.createLine(k) 102 98 local offset = 0 99 -- destroy config line, if it already exists (otherwise would cause an error) 103 100 if winMgr:isWindowPresent("orxonox/SingleplayerConfigMenu/MiscConfigPane/ConfigCommand" .. k) then 104 101 winMgr:destroyWindow("orxonox/SingleplayerConfigMenu/MiscConfigPane/ConfigCommand" .. k) 105 102 end 103 -- content window for the entire line 106 104 local line = winMgr:createWindow("DefaultWindow", "orxonox/SingleplayerConfigMenu/MiscConfigPane/ConfigCommand" .. k) 107 105 line:setHeight(CEGUI.UDim(0, P.lineHeight)) 108 106 line:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, P.lineHeight*(k-1)))) 109 107 108 -- config name 110 109 local command = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/SingleplayerConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Command") 111 110 command:setText(P.nameList[k]) … … 115 114 offset = offset + P.commandWidth + P.spaceWidth 116 115 116 -- config value (editable) 117 117 local configvalue = winMgr:createWindow("MenuWidgets/Editbox", "orxonox/SingleplayerConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Configvalue") 118 118 configvalue:setProperty("ReadOnly", "set:False") … … 121 121 configvalue:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.editboxWidth), CEGUI.UDim(0.9, 0))) 122 122 configvalue:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.05, 0))) 123 -- enable the reset button if the value changed 123 124 orxonox.GUIManager:subscribeEventHelper(configvalue, "TextAccepted", P.name .. ".SingleplayerConfigEditbox_textAccepted") 124 125 line:addChildWindow(configvalue) 125 126 offset = offset + P.editboxWidth + P.spaceWidth 126 127 128 -- reset button (only available when value changed) 127 129 local reset = winMgr:createWindow("MenuWidgets/Button", "orxonox/SingleplayerConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Reset") 128 130 reset:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.resetWidth), CEGUI.UDim(0.9, 0))) … … 154 156 function P.SingleplayerConfigOKButton_clicked(e) 155 157 for k,v in pairs(P.commandList) do 158 -- save the changes 156 159 local editbox = winMgr:getWindow("orxonox/SingleplayerConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Configvalue") 157 160 orxonox.CommandExecutor:execute("config " .. P.commandList[k] .. " " .. editbox:getText()) … … 185 188 local commandNr = tonumber(match()) 186 189 190 -- reload the old value 187 191 local editbox = winMgr:getWindow("orxonox/SingleplayerConfigMenu/MiscConfigPane/ConfigCommand" .. commandNr .. "/Configvalue") 188 192 local value = orxonox.CommandExecutor:query("getConfig " .. P.commandList[commandNr]) -
code/branches/menue/data/gui/scripts/SingleplayerMenu.lua
r8945 r8964 19 19 P.createFilterTab("Show All", nil) 20 20 21 SingleplayerSelectionChanged() 21 -- update description and screenshot boxes 22 P.SingleplayerSelectionChanged() 22 23 23 24 --buttons are arranged in a 1x3 matrix … … 47 48 if level ~= nil then 48 49 local levelXMLFilename = level:getXMLFilename() 50 -- create an imageset for each screenshot 49 51 local imageName = level:getScreenshot() 50 52 if imageName ~= "" then … … 89 91 end 90 92 table.insert(P.activeTabIndexes, tabIndexes) 91 listbox:subscribeEvent("ItemSelectionChanged", "SingleplayerSelectionChanged") 93 -- listen to selection changes 94 orxonox.GUIManager:subscribeEventHelper(listbox, "ItemSelectionChanged", P.name..".SingleplayerSelectionChanged") 92 95 local tabControl = winMgr:getWindow("orxonox/SingleplayerTabControl") 93 tabControl:subscribeEvent("TabSelectionChanged", "SingleplayerSelectionChanged")96 orxonox.GUIManager:subscribeEventHelper(tabControl, "TabSelectionChanged", P.name..".SingleplayerSelectionChanged") 94 97 if listbox:getItemCount() > 0 then 95 98 tabControl:addChildWindow(tabName) … … 103 106 local choice = listbox:getFirstSelectedItem() 104 107 if choice ~= nil then 108 -- get the right tab and the right index 105 109 local tabIndexes = P.activeTabIndexes[tabControl:getSelectedTabIndex()+1] 106 110 local index = tabIndexes[listbox:getItemIndex(choice)+1] … … 111 115 end 112 116 113 function SingleplayerSelectionChanged(e)117 function P.SingleplayerSelectionChanged(e) 114 118 local levelImage = winMgr:getWindow("orxonox/SingleplayerLevelImage") 115 119 local levelDescription = winMgr:getWindow("orxonox/SingleplayerLevelDescription") … … 119 123 local levelXMLFilename = level:getXMLFilename() 120 124 local imageName = level:getScreenshot() 125 -- set the screenshot and the description for the selected level 121 126 levelImage:setProperty("Image", "set:"..levelXMLFilename..imageName.." image:full_image") 122 127 levelDescription:setText(level:getDescription()) 128 -- only enable config button for "gametype" levels 123 129 if level:hasTag("gametype") then 124 130 configButton:setProperty("Disabled", "False") … … 127 133 end 128 134 else 135 -- also take care of "no level selected" 129 136 levelImage:setProperty("Image", nil) 130 137 levelDescription:setText("") … … 144 151 local level = P.SingleplayerGetSelectedLevel() 145 152 if level ~= nil then 146 local X= showMenuSheet("SingleplayerConfigMenu")147 X:loadConfig(level)153 local configMenu = showMenuSheet("SingleplayerConfigMenu") 154 configMenu:loadConfig(level) 148 155 end 149 156 end
Note: See TracChangeset
for help on using the changeset viewer.