|
Last change
on this file since 6517 was
6459,
checked in by rgrieder, 16 years ago
|
|
Simplified BasicGUI construction. Just give the name of the GUI as argument. The rest will be deduced.
|
-
Property svn:eol-style set to
native
|
|
File size:
1.4 KB
|
| Line | |
|---|
| 1 | -- SingleplayerMenu.lua |
|---|
| 2 | |
|---|
| 3 | BasicGUI = require("BasicGUI") |
|---|
| 4 | local P = BasicGUI:new("SingleplayerMenu") |
|---|
| 5 | if _REQUIREDNAME == nil then |
|---|
| 6 | SingleplayerMenu = P |
|---|
| 7 | else |
|---|
| 8 | _G[_REQUIREDNAME] = P |
|---|
| 9 | end |
|---|
| 10 | |
|---|
| 11 | function P:init() |
|---|
| 12 | listbox = winMgr:getWindow("orxonox/SingleplayerLevelListbox") |
|---|
| 13 | preselect = orxonox.LevelManager:getInstance():getDefaultLevel() |
|---|
| 14 | orxonox.LevelManager:getInstance():compileAvailableLevelList() |
|---|
| 15 | local levelList = {} |
|---|
| 16 | local index = 0 |
|---|
| 17 | local level = "" |
|---|
| 18 | while true do |
|---|
| 19 | level = orxonox.LevelManager:getInstance():getAvailableLevelListItem(index) |
|---|
| 20 | if level == "" then |
|---|
| 21 | break |
|---|
| 22 | end |
|---|
| 23 | table.insert(levelList, level) |
|---|
| 24 | index = index + 1 |
|---|
| 25 | end |
|---|
| 26 | table.sort(levelList) |
|---|
| 27 | for k,v in pairs(levelList) do |
|---|
| 28 | item = CEGUI.createListboxTextItem(v) |
|---|
| 29 | item:setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush") |
|---|
| 30 | CEGUI.toListbox(listbox):addItem(item) |
|---|
| 31 | if v .. ".oxw" == preselect then |
|---|
| 32 | listbox:setItemSelectState(item, true) |
|---|
| 33 | end |
|---|
| 34 | end |
|---|
| 35 | end |
|---|
| 36 | |
|---|
| 37 | function P.SingleplayerStartButton_clicked(e) |
|---|
| 38 | choice = winMgr:getWindow("orxonox/SingleplayerLevelListbox"):getFirstSelectedItem() |
|---|
| 39 | if choice then |
|---|
| 40 | orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw") |
|---|
| 41 | orxonox.execute("startGame") |
|---|
| 42 | hideAllGUIs() |
|---|
| 43 | end |
|---|
| 44 | end |
|---|
| 45 | |
|---|
| 46 | function P.SingleplayerBackButton_clicked(e) |
|---|
| 47 | hideGUI(P.filename) |
|---|
| 48 | end |
|---|
| 49 | |
|---|
| 50 | return P |
|---|
| 51 | |
|---|
Note: See
TracBrowser
for help on using the repository browser.