Changeset 8912 for code/branches/menue/data/gui/scripts
- Timestamp:
- Nov 2, 2011, 1:31:12 PM (13 years ago)
- Location:
- code/branches/menue/data/gui/scripts
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/menue/data/gui/scripts/CreditsMenu.lua
r8079 r8912 14 14 function P.onShow() 15 15 local description = winMgr:getWindow("orxonox/CreditsText") 16 description:setProperty("HorzFormatting", "WordWrapLeftAligned")17 description:setProperty("VertFormatting", "TopAligned")18 description:setText(" Orxonox version 0.0.3 \n\n Programming Language: C++ - lua - tcl \n Environment: OpenAL - Ogre - OIS - CEGUI - enet - ODE \n Licence: GNU General Public Licence - Creative Commons \n http://www.orxonox.net \n \n Credits:")19 16 20 description:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -P.scrollbarWidth), CEGUI.UDim(1.0, 0)))21 17 height = getStaticTextWindowHeight(description) 22 description:set Height(CEGUI.UDim(0, height))18 description:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -P.scrollbarWidth), CEGUI.UDim(0.0, height))) 23 19 end 24 20 -
code/branches/menue/data/gui/scripts/SingleplayerMenu.lua
r8894 r8912 4 4 5 5 P.levelList = {} 6 P.activeTabIndexes = {} 7 P.scrollbarWidth = 13 6 8 7 9 function P.onLoad() … … 9 11 10 12 -- create tabs with desired tab as argument (nil for all) 11 P.createFilterTab("Show All", nil)12 13 P.createFilterTab("Tests", "test") 13 14 P.createFilterTab("Tutorials", "tutorial") … … 15 16 P.createFilterTab("SP?", "singleplayer") 16 17 P.createFilterTab("Presentations", "presentation") 18 P.createFilterTab("Show All", nil) 17 19 18 --buttons are arranged in a 1x 2matrix20 --buttons are arranged in a 1x3 matrix 19 21 P:setButton(1, 1, { 20 22 ["button"] = winMgr:getWindow("orxonox/SingleplayerStartButton"), … … 23 25 24 26 P:setButton(1, 2, { 27 ["button"] = winMgr:getWindow("orxonox/SingleplayerConfigButton"), 28 ["callback"] = P.SingleplayerConfigButton_clicked 29 }) 30 31 P:setButton(1, 3, { 25 32 ["button"] = winMgr:getWindow("orxonox/SingleplayerBackButton"), 26 33 ["callback"] = P.SingleplayerBackButton_clicked … … 36 43 level = orxonox.LevelManager:getInstance():getAvailableLevelListItem(index) 37 44 if level ~= nil then 45 local levelXMLFilename = level:getXMLFilename() 46 local imageName = level:getScreenshot() 47 if imageName ~= "" then 48 CEGUI.ImagesetManager:getSingleton():createImagesetFromImageFile(levelXMLFilename..imageName, imageName) 49 else 50 CEGUI.ImagesetManager:getSingleton():createImagesetFromImageFile(levelXMLFilename..imageName, "noScreenshot.png") 51 end 38 52 table.insert(P.levelList, level) 39 53 end … … 44 58 function P.createFilterTab(name, tag) 45 59 -- create unique tab window name 46 local tabName = "orxonox/SingleplayerLevel Listbox"60 local tabName = "orxonox/SingleplayerLevelTab" 47 61 if tag ~= nil then 48 62 tabName = tabName..tag … … 50 64 -- add new tab window with desired name 51 65 local tabControl = winMgr:getWindow("orxonox/SingleplayerTabControl") 52 local newWindow = winMgr:createWindow("MenuWidgets/Listbox", tabName)53 newWindow:setText(name)54 newWindow:setProperty("UnifiedMaxSize", "{{1,0},{1,0}}")55 newWindow:setProperty("UnifiedAreaRect", "{{0.05,0},{0.15,0},{0.95,0},{0.85,0}}")66 local listbox = CEGUI.toListbox(winMgr:createWindow("MenuWidgets/Listbox", tabName)) 67 listbox:setText(name) 68 listbox:setProperty("UnifiedMaxSize", "{{1,0},{1,0}}") 69 listbox:setProperty("UnifiedAreaRect", "{{0.05,0},{0.1,0},{0.5,0},{0.7,0}}") 56 70 tabControl:addChildWindow(tabName) 57 71 -- fill listbox with items 58 local listbox = CEGUI.toListbox(newWindow)59 72 listbox:resetList() 60 73 orxonox.GUIManager:setItemTooltipsEnabledHelper(listbox, true) 61 74 local preselect = orxonox.LevelManager:getInstance():getDefaultLevel() 75 local tabIndexes = {} 62 76 for k,v in pairs(P.levelList) do 63 77 -- only add level if it has desired tag … … 66 80 item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush") 67 81 listbox:addItem(item) 82 table.insert(tabIndexes, k) 68 83 if v:getXMLFilename() == preselect then 69 84 listbox:setItemSelectState(item, true) … … 72 87 end 73 88 end 89 table.insert(P.activeTabIndexes, tabIndexes) 90 listbox:subscribeEvent("ItemSelectionChanged", "SingleplayerSelectionChanged") 91 tabControl:subscribeEvent("TabSelectionChanged", "SingleplayerSelectionChanged") 92 SingleplayerSelectionChanged() 74 93 end 75 94 76 function P.Singleplayer StartButton_clicked(e)95 function P.SingleplayerGetSelectedLevel() 77 96 -- choose the active listbox 78 97 local tabControl = CEGUI.toTabControl(winMgr:getWindow("orxonox/SingleplayerTabControl")) … … 80 99 local choice = listbox:getFirstSelectedItem() 81 100 if choice ~= nil then 82 local index = listbox:getItemIndex(choice) 83 local level = P.levelList[index+1] 84 if level ~= nil then 85 orxonox.execute("startGame " .. level:getXMLFilename()) 86 hideAllMenuSheets() 87 end 101 local tabIndexes = P.activeTabIndexes[tabControl:getSelectedTabIndex()+1] 102 local index = tabIndexes[listbox:getItemIndex(choice)+1] 103 return P.levelList[index] 104 else 105 return nil 88 106 end 107 end 108 109 function SingleplayerSelectionChanged(e) 110 local level = P.SingleplayerGetSelectedLevel() 111 if level ~= nil then 112 local levelXMLFilename = level:getXMLFilename() 113 local imageName = level:getScreenshot() 114 local levelImage = winMgr:getWindow("orxonox/SingleplayerLevelImage") 115 levelImage:setProperty("Image", "set:"..levelXMLFilename..imageName.." image:full_image") 116 local levelDescription = winMgr:getWindow("orxonox/SingleplayerLevelDescription") 117 local height = getStaticTextWindowHeight(levelDescription) 118 -- local width = getStaticTextWindowWidth(levelDescription) 119 levelDescription:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -P.scrollbarWidth), CEGUI.UDim(0.0, height))) 120 levelDescription:setText(level:getDescription()) 121 end 122 end 123 124 function P.SingleplayerStartButton_clicked(e) 125 local level = P.SingleplayerGetSelectedLevel() 126 if level ~= nil then 127 orxonox.execute("startGame " .. level:getXMLFilename()) 128 hideAllMenuSheets() 129 end 130 end 131 132 function P.SingleplayerConfigButton_clicked(e) 133 hideMenuSheet(P.name) 89 134 end 90 135
Note: See TracChangeset
for help on using the changeset viewer.