Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/menu/data/gui/scripts/MainMenu.lua @ 7663

Last change on this file since 7663 was 7663, checked in by konrad, 13 years ago

key handling in some menu sheets has been added.

  • Property svn:eol-style set to native
File size: 2.4 KB
Line 
1-- MainMenu.lua
2
3local P = createMenuSheet("MainMenu")
4P.loadAlong = { "SingleplayerMenu", "MultiplayerMenu", "SettingsMenu", "CreditsMenu" }
5
6P.buttonList = {}
7
8P.testArray = {}
9
10
11function P.onLoad()
12    local item = {
13            ["button"] = winMgr:getWindow("orxonox/QuickGameTestButton"),
14            ["function"]  = P.QuickGameTestButton_clicked
15    }
16    table.insert(P.buttonList,item)
17
18    item = {
19            ["button"] = winMgr:getWindow("orxonox/SingleplayerButton"),
20            ["function"]  = P.SingleplayerButton_clicked
21    }
22    table.insert(P.buttonList,item)
23
24    item = {
25            ["button"] = winMgr:getWindow("orxonox/MultiplayerButton"),
26            ["function"]  = P.MultiplayerButton_clicked
27    }
28    table.insert(P.buttonList,item)
29
30    item = {
31            ["button"] = winMgr:getWindow("orxonox/SettingsButton"),
32            ["function"]  = P.SettingsButton_clicked
33    }
34    table.insert(P.buttonList,item)
35
36    item = {
37            ["button"] = winMgr:getWindow("orxonox/CreditsButton"),
38            ["function"]  = P.CreditsButton_clicked
39    }
40    table.insert(P.buttonList,item)
41
42    item = {
43            ["button"] = winMgr:getWindow("orxonox/ExitButton"),
44            ["function"]  = P.ExitButton_clicked
45    }
46    table.insert(P.buttonList,item) 
47end
48
49function P.onShow()
50    P.oldindex = -2
51    P.index = -1
52end
53
54-- events for MainMenu
55function P.QuickGameTestButton_clicked(e)
56    hideAllMenuSheets()
57    orxonox.execute("startGame")
58end
59
60function P.SingleplayerButton_clicked(e)
61    showMenuSheet("SingleplayerMenu", true)
62end
63
64function P.MultiplayerButton_clicked(e)
65    showMenuSheet("MultiplayerMenu", true)
66end
67
68function P.SettingsButton_clicked(e)
69    showMenuSheet("SettingsMenu", true)
70end
71
72function P.CreditsButton_clicked(e)
73    showMenuSheet("CreditsMenu", true)
74end
75
76function P.ExitButton_clicked(e)
77    orxonox.execute("exit")
78end
79
80
81--[[
82list = {}
83local item =
84{
85    ["button"] = buttonWindow,
86    ["function"]  = buttonFunction,
87}
88table.insert(list, item)
89item = list[i]
90
91for i,item in pairs(list) do
92    button = item["button"]
93end
94
95--]]
96--[[
97function createList()
98    list = {}
99
100    local j
101    while j < P.loadAlong
102        local item =
103        {
104            ["button"] = buttonWindow,
105            ["function"]  = buttonFunction,
106        }
107        table.insert(list, item)
108    end
109
110--]]
111
112function P.onKeyPressed() 
113    cout(0,code)
114    buttonIteratorHelper(P.buttonList, code, P, 6, 1)
115    --indexTester(P.buttonList,code,P,6,1)
116end
117
118return P
119
Note: See TracBrowser for help on using the repository browser.