Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/data/gui/scripts/MainMenu.lua @ 7726

Last change on this file since 7726 was 7689, checked in by dafrick, 14 years ago

Merging menu branch to trunk.

  • Property svn:eol-style set to native
File size: 2.0 KB
Line 
1-- MainMenu.lua
2
3local P = createMenuSheet("MainMenu")
4P.loadAlong = { "SingleplayerMenu", "MultiplayerMenu", "SettingsMenu", "CreditsMenu" }
5
6P.buttonList = {}
7
8function P.onLoad()
9    --buttons are arranged in a 6x1 Matrix (list)
10    local item = {
11            ["button"] = winMgr:getWindow("orxonox/QuickGameTestButton"),
12            ["function"]  = P.QuickGameTestButton_clicked
13    }
14    table.insert(P.buttonList,item)
15
16    item = {
17            ["button"] = winMgr:getWindow("orxonox/SingleplayerButton"),
18            ["function"]  = P.SingleplayerButton_clicked
19    }
20    table.insert(P.buttonList,item)
21
22    item = {
23            ["button"] = winMgr:getWindow("orxonox/MultiplayerButton"),
24            ["function"]  = P.MultiplayerButton_clicked
25    }
26    table.insert(P.buttonList,item)
27
28    item = {
29            ["button"] = winMgr:getWindow("orxonox/SettingsButton"),
30            ["function"]  = P.SettingsButton_clicked
31    }
32    table.insert(P.buttonList,item)
33
34    item = {
35            ["button"] = winMgr:getWindow("orxonox/CreditsButton"),
36            ["function"]  = P.CreditsButton_clicked
37    }
38    table.insert(P.buttonList,item)
39
40    item = {
41            ["button"] = winMgr:getWindow("orxonox/ExitButton"),
42            ["function"]  = P.ExitButton_clicked
43    }
44    table.insert(P.buttonList,item) 
45end
46
47function P.onShow()
48    --indices to iterate through buttonlist
49    P.oldindex = -2
50    P.index = -1
51end
52
53-- events for MainMenu
54function P.QuickGameTestButton_clicked(e)
55    hideAllMenuSheets()
56    orxonox.execute("startGame")
57end
58
59function P.SingleplayerButton_clicked(e)
60    showMenuSheet("SingleplayerMenu", true)
61end
62
63function P.MultiplayerButton_clicked(e)
64    showMenuSheet("MultiplayerMenu", true)
65end
66
67function P.SettingsButton_clicked(e)
68    showMenuSheet("SettingsMenu", true)
69end
70
71function P.CreditsButton_clicked(e)
72    showMenuSheet("CreditsMenu", true)
73end
74
75function P.ExitButton_clicked(e)
76    orxonox.execute("exit")
77end
78
79function P.onKeyPressed() 
80    buttonIteratorHelper(P.buttonList, code, P, 6, 1)
81end
82
83return P
84
Note: See TracBrowser for help on using the repository browser.