Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/masterserver2/data/gui/scripts/InGameMenu.lua @ 8577

Last change on this file since 8577 was 7877, checked in by dafrick, 14 years ago

Some minor simplification in InGameMenu.lua

  • Property svn:eol-style set to native
File size: 1.7 KB
Line 
1-- InGameMenu.lua
2
3local P = createMenuSheet("InGameMenu")
4P.loadAlong = { "DecisionPopup" }
5
6P.buttonList = {}
7
8function P.onLoad()
9    P.multiplayerMode = "startClient" 
10
11    --button are arranged in a 4x1 matrix, the left lower item is nil
12    local item = {
13            ["button"] = winMgr:getWindow("orxonox/InGameMenu_ReturnButton"),
14            ["function"]  = P.button_settings_clicked
15    }
16    P.buttonList[1] = item
17
18    local item = {
19            ["button"] = winMgr:getWindow("orxonox/InGameMenu_MainMenuButton"),
20            ["function"]  = P.button_mainmenu_clicked
21    }
22    P.buttonList[2] = item
23
24    local item = {
25            ["button"] = winMgr:getWindow("orxonox/InGameMenu_SettingsButton"),
26            ["function"]  = P.button_settings_clicked
27    }
28    P.buttonList[3] = item
29
30    local item = {
31            ["button"] = winMgr:getWindow("orxonox/InGameMenu_QuitButton"),
32            ["function"]  = P.button_quit_clicked
33    }
34    P.buttonList[4] = item
35
36end
37
38function P.onShow()
39    --indices to iterate through buttonlist
40    P.oldindex = -2
41    P.index = -1
42end
43
44-- events for ingamemenu
45function P.button_quit_clicked(e)
46    openDecisionPopup( "Do you really want to quit the game?", InGameMenu.callback )
47end
48
49function P.button_mainmenu_clicked(e)
50    orxonox.execute("startMainMenu")
51    hideMenuSheet("InGameMenu")
52end
53
54function P.button_settings_clicked(e)
55    showMenuSheet("SettingsMenu", true)
56end
57
58function P.button_return_clicked(e)
59    hideMenuSheet("InGameMenu")
60end
61
62function P.callback(doExit)
63    if doExit then
64        hideMenuSheet("InGameMenu")
65        orxonox.execute("exit")
66    else 
67        P.onShow()
68    end
69end
70
71function P.onKeyPressed() 
72    buttonIteratorHelper(P.buttonList, code, P, 4, 1)
73end
74
75return P
76
Note: See TracBrowser for help on using the repository browser.