Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/mac_osx2/data/gui/scripts/MiscConfigMenu.lua @ 11238

Last change on this file since 11238 was 8079, checked in by landauf, 14 years ago

merged usability branch back to trunk

incomplete summary of the changes in this branch:

  • enhanced keyboard navigation in GUIs
  • implemented new graphics menu and changeable window size at runtime
  • added developer mode
  • HUD shows if game is paused, game pauses if ingame menu is opened
  • removed a few obsolete commands and hid some that are more for internal use
  • numpad works in console and gui
  • faster loading of level info
  • enhanced usage of compositors (Shader class)
  • improved camera handling, configurable FOV and aspect ratio
  • Property svn:eol-style set to native
File size: 7.0 KB
Line 
1-- MiscConfigMenu.lua
2
3local P = createMenuSheet("MiscConfigMenu", true, TriBool.True, TriBool.True)
4
5P.commandList = {}
6P.nameList = {}
7P.linesList = {}
8
9P.sampleWindow = nil
10
11P.lineHeight = 0
12P.commandWidth = 0
13P.configWidth = 0
14P.resetWidth = 0
15P.spaceWidth = 0
16
17function P.onLoad()
18
19    P.commandList = {}
20    table.insert(P.commandList, "KeyBinder mouseSensitivity_")
21    table.insert(P.commandList, "KeyBinder mouseSensitivityDerived_")
22    table.insert(P.commandList, "KeyBinder bDeriveMouseInput_")
23    table.insert(P.commandList, "KeyBinder mouseWheelStepSize_")
24    table.insert(P.commandList, "Shell maxHistoryLength_")
25    table.insert(P.commandList, "Core bStartIOConsole_")
26    table.insert(P.commandList, "Game fpsLimit_")
27    table.insert(P.commandList, "Spectator speed_")
28    table.insert(P.commandList, "SpaceShip bInvertYAxis_")
29    table.insert(P.commandList, "LevelManager defaultLevelName_")
30    table.insert(P.commandList, "Gametype initialStartCountdown_")
31    table.insert(P.commandList, "Gametype bAutoStart_")
32    table.insert(P.commandList, "Gametype numberOfBots_")
33    table.insert(P.commandList, "UnderAttack gameTime_")
34    table.insert(P.commandList, "TeamDeathmatch teams_")
35    table.insert(P.commandList, "HumanPlayer nick_")
36    table.insert(P.commandList, "ChatOverlay displayTime_")
37    table.insert(P.commandList, "Core bDevMode_")
38
39    P.nameList = {}
40    table.insert(P.nameList, "Mouse sensitivity")
41    table.insert(P.nameList, "Mouse acceleration")
42    table.insert(P.nameList, "Derive mouse input")
43    table.insert(P.nameList, "Mouse wheel stepsize")
44    table.insert(P.nameList, "Shell: max. History length")
45    table.insert(P.nameList, "Start IOConsole")
46    table.insert(P.nameList, "FPS limit")
47    table.insert(P.nameList, "Spectator speed")
48    table.insert(P.nameList, "Invert Y-axis")
49    table.insert(P.nameList, "Default level")
50    table.insert(P.nameList, "Start countdown")
51    table.insert(P.nameList, "Autostart")
52    table.insert(P.nameList, "Number of Bots")
53    table.insert(P.nameList, "UnderAttack: game time")
54    table.insert(P.nameList, "TeamDeathmatch: Number of teams")
55    table.insert(P.nameList, "Playername")
56    table.insert(P.nameList, "Chat: display time")
57    table.insert(P.nameList, "Developer's Mode")
58
59    P.linesList = {}
60
61    --Calculate design parameters:
62    P.sampleWindow = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/MiscConfigMenu/MiscConfigPane/SampleWindow")
63    P.sampleWindow:setText("SampleText")
64
65    local size = getMinTextSize(P.sampleWindow)
66    P.lineHeight = size[1]
67
68    P.commandWidth = 0
69    for k,v in pairs(P.commandList) do
70        P.sampleWindow:setText(P.nameList[k])
71        size = getMinTextSize(P.sampleWindow)
72        if size[2] > P.commandWidth then
73            P.commandWidth = size[2]
74        end
75    end
76
77    P.sampleWindow:setText("configure")
78    size = getMinTextSize(P.sampleWindow)
79    P.configWidth = size[2]+20
80
81    P.sampleWindow:setText("reset")
82    size = getMinTextSize(P.sampleWindow)
83    P.resetWidth = size[2]+20
84
85    P.spaceWidth = math.floor(1/8*P.configWidth)
86
87    P.createLines()
88
89    P:setButton(1, 1, {
90            ["button"] = winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigBackButton"),
91            ["callback"]  = P.MiscConfigBackButton_clicked
92    })
93end
94
95function P.createLine(k)
96    local offset = 0
97    local line = winMgr:createWindow("DefaultWindow", "orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k)
98    line:setHeight(CEGUI.UDim(0, P.lineHeight))
99    line:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, P.lineHeight*(k-1))))
100
101    local command = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Command")
102    command:setText(P.nameList[k])
103    command:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.commandWidth), CEGUI.UDim(1, 0)))
104    command:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0, 0)))
105    line:addChildWindow(command)
106    offset = offset + P.commandWidth + P.spaceWidth
107
108    local configvalue = winMgr:createWindow("MenuWidgets/Editbox", "orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Configvalue")
109    configvalue:setProperty("ReadOnly", "set:False")
110    local value = orxonox.CommandExecutor:query("getConfig " .. P.commandList[k])
111    configvalue:setText(value)
112    P.sampleWindow:setText(value)
113    local size = getMinTextSize(P.sampleWindow)
114    local configvalueWidth = 2*size[2]
115    configvalue:setSize(CEGUI.UVector2(CEGUI.UDim(0, configvalueWidth), CEGUI.UDim(0.9, 0)))
116    configvalue:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.05, 0)))
117    line:addChildWindow(configvalue)
118    offset = offset + configvalueWidth + P.spaceWidth
119
120    local config = winMgr:createWindow("MenuWidgets/Button", "orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Config")
121    config:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.configWidth), CEGUI.UDim(0.9, 0)))
122    config:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.05, 0)))
123    config:setText("configure")
124    orxonox.GUIManager:subscribeEventHelper(config, "Clicked", P.name .. ".MiscConfigConfigure_clicked")
125    line:addChildWindow(config)
126    offset = offset + P.configWidth + P.spaceWidth
127
128    local reset = winMgr:createWindow("MenuWidgets/Button", "orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Reset")
129    reset:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.resetWidth), CEGUI.UDim(0.9, 0)))
130    reset:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.05, 0)))
131    reset:setText("reset")
132    orxonox.GUIManager:subscribeEventHelper(reset, "Clicked", P.name .. ".MiscConfigReset_clicked")
133    line:addChildWindow(reset)
134    reset:setEnabled(false)
135    offset = offset + P.resetWidth + P.spaceWidth
136
137    line:setWidth(CEGUI.UDim(0, offset))
138
139    return line
140end
141
142function P.createLines()
143    local window = winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigPane")
144
145    for k,v in pairs(P.commandList) do
146        local line = P.createLine(k)
147        table.insert(P.linesList, line)
148        window:addChildWindow(line)
149    end
150
151    local pane = tolua.cast(window, "CEGUI::ScrollablePane")
152    pane:setVerticalStepSize(getScrollingStepSize(window))
153end
154
155function P.MiscConfigReset_clicked(e)
156    local we = CEGUI.toWindowEventArgs(e)
157    local name = we.window:getName()
158
159    local match = string.gmatch(name, "%d+")
160    local commandNr = tonumber(match())
161
162    -- TODO: Implement reset.
163end
164
165function P.MiscConfigConfigure_clicked(e)
166    local we = CEGUI.toWindowEventArgs(e)
167    local name = we.window:getName()
168
169    local match = string.gmatch(name, "%d+")
170    local commandNr = tonumber(match())
171
172    local window = winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. commandNr .. "/Configvalue")
173
174    orxonox.CommandExecutor:execute("config " .. P.commandList[commandNr] .. " " .. window:getText())
175    local value = orxonox.CommandExecutor:query("getConfig " .. P.commandList[commandNr])
176    window:setText(value)
177end
178
179function P.MiscConfigBackButton_clicked(e)
180    hideMenuSheet("MiscConfigMenu")
181end
182
183return P
Note: See TracBrowser for help on using the repository browser.