Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/usability/data/gui/scripts/MiscConfigMenu.lua @ 11878

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

Developer's mode. Is a ConfigValue, by default on except in release mode. If on it should help the developer, if off, it should obscure things we don't want the user to have to deal with.
So far it ticks the showAll button in the Singleplayer and Host menu, if on. It also sets the start countdown to 0 if on.
If you have some more ideas on how to make life easier for both developers and users, feel free to implement it yourself ot mention it to me.

  • Property svn:eol-style set to native
File size: 7.0 KB
RevLine 
[7006]1-- MiscConfigMenu.lua
2
[7012]3local P = createMenuSheet("MiscConfigMenu", true, TriBool.True, TriBool.True)
[7006]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 = {}
[7013]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_")
[7006]36    table.insert(P.commandList, "ChatOverlay displayTime_")
[8040]37    table.insert(P.commandList, "Core bDevMode_")
[7006]38
39    P.nameList = {}
[7013]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")
[7403]54    table.insert(P.nameList, "TeamDeathmatch: Number of teams")
[7013]55    table.insert(P.nameList, "Playername")
56    table.insert(P.nameList, "Chat: display time")
[8040]57    table.insert(P.nameList, "Developer's Mode")
[7006]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
[7924]89    P:setButton(1, 1, {
90            ["button"] = winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigBackButton"),
91            ["callback"]  = P.MiscConfigBackButton_clicked
92    })
[7006]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")
[7284]110    local value = orxonox.CommandExecutor:query("getConfig " .. P.commandList[k])
[7006]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)
[7013]134    reset:setEnabled(false)
[7006]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
[7013]174    orxonox.CommandExecutor:execute("config " .. P.commandList[commandNr] .. " " .. window:getText())
[7284]175    local value = orxonox.CommandExecutor:query("getConfig " .. P.commandList[commandNr])
[7006]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.