Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

Small adjustment to MainMenu.lua to illustrate how to change how a button looks like.

  • Property svn:eol-style set to native
File size: 1.9 KB
Line 
1-- MainMenu.lua
2
3local P = createMenuSheet("MainMenu")
4P.loadAlong = { "SingleplayerMenu", "MultiplayerMenu", "SettingsMenu", "CreditsMenu" }
5
6P.index = 0
7
8-- events for MainMenu
9function P.QuickGameTestButton_clicked(e)
10    hideAllMenuSheets()
11    orxonox.execute("startGame")
12end
13
14function P.SingleplayerButton_clicked(e)
15    showMenuSheet("SingleplayerMenu", true)
16end
17
18function P.MultiplayerButton_clicked(e)
19    showMenuSheet("MultiplayerMenu", true)
20end
21
22function P.SettingsButton_clicked(e)
23    showMenuSheet("SettingsMenu", true)
24end
25
26function P.CreditsButton_clicked(e)
27    showMenuSheet("CreditsMenu", true)
28end
29
30function P.ExitButton_clicked(e)
31    orxonox.execute("exit")
32end
33
34function P.Key_clicked(e)
35    local we = tolua.cast(e, "CEGUI::KeyEventArgs")
36    cout(0, tostring(we.scancode))
37    if tostring(we.scancode) == "15" then
38        P.index = P.index + 1
39        local window = winMgr:getWindow("orxonox/MainMenuBackground")
40        if P.index == window:getChildCount() then
41            P.index = 1
42        end
43        local child = window:getChildAtIdx(P.index-1)
44        child:setProperty("NormalImageRightEdge", string.sub(child:getProperty("NormalImageRightEdge"),1,-7) .. "Highlight")
45        child:setProperty("NormalImageLeftEdge", string.sub(child:getProperty("NormalImageLeftEdge"),1,-7) .. "Highlight")
46        child:setProperty("NormalImageBackground", string.sub(child:getProperty("NormalImageBackground"),1,-7) .. "Highlight")
47    elseif tostring(we.scancode) == "28" and P.index ~= 0 then
48        if P.index == 1 then
49            P.QuickGameTestButton_clicked()
50        elseif P.index == 2 then
51            P.SingleplayerButton_clicked()
52        elseif P.index == 3 then
53            P.MultiplayerButton_clicked()
54        elseif P.index == 4 then
55            P.SettingsButton_clicked()
56        elseif P.index == 5 then
57            P.CreditsButton_clicked()
58        elseif P.index == 6 then
59            P.ExitButton_clicked()
60        end
61    end
62end
63
64return P
65
Note: See TracBrowser for help on using the repository browser.