Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/hud/data/gui/scripts/MiscConfigMenu.lua @ 8948

Last change on this file since 8948 was 8929, checked in by mspaling, 13 years ago

added xmlport for rvnames and misc menu options

  • Property svn:eol-style set to native
File size: 7.2 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    table.insert(P.commandList, "HUDNavigation MarkerLimit_")
39    table.insert(P.commandList, "HUDNavigation showDistance")
40
41    P.nameList = {}
42    table.insert(P.nameList, "Mouse sensitivity")
43    table.insert(P.nameList, "Mouse acceleration")
44    table.insert(P.nameList, "Derive mouse input")
45    table.insert(P.nameList, "Mouse wheel stepsize")
46    table.insert(P.nameList, "Shell: max. History length")
47    table.insert(P.nameList, "Start IOConsole")
48    table.insert(P.nameList, "FPS limit")
49    table.insert(P.nameList, "Spectator speed")
50    table.insert(P.nameList, "Invert Y-axis")
51    table.insert(P.nameList, "Default level")
52    table.insert(P.nameList, "Start countdown")
53    table.insert(P.nameList, "Autostart")
54    table.insert(P.nameList, "Number of Bots")
55    table.insert(P.nameList, "UnderAttack: game time")
56    table.insert(P.nameList, "TeamDeathmatch: Number of teams")
57    table.insert(P.nameList, "Playername")
58    table.insert(P.nameList, "Chat: display time")
59    table.insert(P.nameList, "Developer's Mode")
60    table.insert(P.nameList, "Marker Limit")
61    table.insert(P.nameList, "Show Distance next to cursor")
62
63    P.linesList = {}
64
65    --Calculate design parameters:
66    P.sampleWindow = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/MiscConfigMenu/MiscConfigPane/SampleWindow")
67    P.sampleWindow:setText("SampleText")
68
69    local size = getMinTextSize(P.sampleWindow)
70    P.lineHeight = size[1]
71
72    P.commandWidth = 0
73    for k,v in pairs(P.commandList) do
74        P.sampleWindow:setText(P.nameList[k])
75        size = getMinTextSize(P.sampleWindow)
76        if size[2] > P.commandWidth then
77            P.commandWidth = size[2]
78        end
79    end
80
81    P.sampleWindow:setText("configure")
82    size = getMinTextSize(P.sampleWindow)
83    P.configWidth = size[2]+20
84
85    P.sampleWindow:setText("reset")
86    size = getMinTextSize(P.sampleWindow)
87    P.resetWidth = size[2]+20
88
89    P.spaceWidth = math.floor(1/8*P.configWidth)
90
91    P.createLines()
92
93    P:setButton(1, 1, {
94            ["button"] = winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigBackButton"),
95            ["callback"]  = P.MiscConfigBackButton_clicked
96    })
97end
98
99function P.createLine(k)
100    local offset = 0
101    local line = winMgr:createWindow("DefaultWindow", "orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k)
102    line:setHeight(CEGUI.UDim(0, P.lineHeight))
103    line:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, P.lineHeight*(k-1))))
104
105    local command = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Command")
106    command:setText(P.nameList[k])
107    command:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.commandWidth), CEGUI.UDim(1, 0)))
108    command:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0, 0)))
109    line:addChildWindow(command)
110    offset = offset + P.commandWidth + P.spaceWidth
111
112    local configvalue = winMgr:createWindow("MenuWidgets/Editbox", "orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Configvalue")
113    configvalue:setProperty("ReadOnly", "set:False")
114    local value = orxonox.CommandExecutor:query("getConfig " .. P.commandList[k])
115    configvalue:setText(value)
116    P.sampleWindow:setText(value)
117    local size = getMinTextSize(P.sampleWindow)
118    local configvalueWidth = 2*size[2]
119    configvalue:setSize(CEGUI.UVector2(CEGUI.UDim(0, configvalueWidth), CEGUI.UDim(0.9, 0)))
120    configvalue:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.05, 0)))
121    line:addChildWindow(configvalue)
122    offset = offset + configvalueWidth + P.spaceWidth
123
124    local config = winMgr:createWindow("MenuWidgets/Button", "orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Config")
125    config:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.configWidth), CEGUI.UDim(0.9, 0)))
126    config:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.05, 0)))
127    config:setText("configure")
128    orxonox.GUIManager:subscribeEventHelper(config, "Clicked", P.name .. ".MiscConfigConfigure_clicked")
129    line:addChildWindow(config)
130    offset = offset + P.configWidth + P.spaceWidth
131
132    local reset = winMgr:createWindow("MenuWidgets/Button", "orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Reset")
133    reset:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.resetWidth), CEGUI.UDim(0.9, 0)))
134    reset:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.05, 0)))
135    reset:setText("reset")
136    orxonox.GUIManager:subscribeEventHelper(reset, "Clicked", P.name .. ".MiscConfigReset_clicked")
137    line:addChildWindow(reset)
138    reset:setEnabled(false)
139    offset = offset + P.resetWidth + P.spaceWidth
140
141    line:setWidth(CEGUI.UDim(0, offset))
142
143    return line
144end
145
146function P.createLines()
147    local window = winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigPane")
148
149    for k,v in pairs(P.commandList) do
150        local line = P.createLine(k)
151        table.insert(P.linesList, line)
152        window:addChildWindow(line)
153    end
154
155    local pane = tolua.cast(window, "CEGUI::ScrollablePane")
156    pane:setVerticalStepSize(getScrollingStepSize(window))
157end
158
159function P.MiscConfigReset_clicked(e)
160    local we = CEGUI.toWindowEventArgs(e)
161    local name = we.window:getName()
162
163    local match = string.gmatch(name, "%d+")
164    local commandNr = tonumber(match())
165
166    -- TODO: Implement reset.
167end
168
169function P.MiscConfigConfigure_clicked(e)
170    local we = CEGUI.toWindowEventArgs(e)
171    local name = we.window:getName()
172
173    local match = string.gmatch(name, "%d+")
174    local commandNr = tonumber(match())
175
176    local window = winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. commandNr .. "/Configvalue")
177
178    orxonox.CommandExecutor:execute("config " .. P.commandList[commandNr] .. " " .. window:getText())
179    local value = orxonox.CommandExecutor:query("getConfig " .. P.commandList[commandNr])
180    window:setText(value)
181end
182
183function P.MiscConfigBackButton_clicked(e)
184    hideMenuSheet("MiscConfigMenu")
185end
186
187return P
Note: See TracBrowser for help on using the repository browser.