[Orxonox-commit 2972] r7670 - code/branches/menu/data/gui/scripts
dafrick at orxonox.net
dafrick at orxonox.net
Wed Nov 24 20:58:13 CET 2010
Author: dafrick
Date: 2010-11-24 20:58:13 +0100 (Wed, 24 Nov 2010)
New Revision: 7670
Modified:
code/branches/menu/data/gui/scripts/InGameMenu.lua
code/branches/menu/data/gui/scripts/SheetManager.lua
Log:
ESC behavior is once again correct.
Kind of hackish, though, but I guess there is really no good way around that seeing that the MainMenu is still a hack.
Modified: code/branches/menu/data/gui/scripts/InGameMenu.lua
===================================================================
--- code/branches/menu/data/gui/scripts/InGameMenu.lua 2010-11-24 17:17:40 UTC (rev 7669)
+++ code/branches/menu/data/gui/scripts/InGameMenu.lua 2010-11-24 19:58:13 UTC (rev 7670)
@@ -11,7 +11,6 @@
function P.button_mainmenu_clicked(e)
orxonox.Game:getInstance():popState()
orxonox.Game:getInstance():popState()
- orxonox.Game:getInstance():requestState("mainmenu")
hideMenuSheet("InGameMenu")
end
Modified: code/branches/menu/data/gui/scripts/SheetManager.lua
===================================================================
--- code/branches/menu/data/gui/scripts/SheetManager.lua 2010-11-24 17:17:40 UTC (rev 7669)
+++ code/branches/menu/data/gui/scripts/SheetManager.lua 2010-11-24 19:58:13 UTC (rev 7670)
@@ -5,6 +5,7 @@
local activeMenuSheets = {size = 0, topSheetTuple = nil}
local menuSheetsRoot = guiMgr:getMenuRootWindow()
local bInGameConsoleClosed = false
+local mainMenuLoaded = false
orxonox.GUIManager:subscribeEventHelper(menuSheetsRoot, "KeyDown", "keyPressed")
-----------------------
@@ -70,7 +71,7 @@
end
-- Count the number of sheets that don't need input till the first that does.
- local counter = noInputSheetCounter()
+ local counter = noInputSheetIndex()
-- Pause game control if this is the first menu to be displayed
-- HUGE HACK?
if bNoInput == false and counter == 0 then
@@ -101,6 +102,11 @@
-- Add sheet to the root window
menuSheetsRoot:addChildWindow(menuSheet.window)
+ -- If sheet is the MainMenu
+ if name == "MainMenu" then
+ mainMenuLoaded = true
+ end
+
-- Handle input distribution
if bNoInput == false then
inputMgr:enterState(menuSheet.inputState)
@@ -119,7 +125,7 @@
activeMenuSheets[i].sheet:hide()
end
end
-
+
menuSheet:show()
menuSheetsRoot:activate()
@@ -163,6 +169,11 @@
activeMenuSheets.size = activeMenuSheets.size - 1
activeMenuSheets.topSheetTuple = activeMenuSheets[activeMenuSheets.size]
+ -- If sheet is the MainMenu
+ if name == "MainMenu" then
+ mainMenuLoaded = false
+ end
+
-- Leave the input state
if not sheetTuple.bNoInput then
inputMgr:leaveState(sheetTuple.sheet.inputState)
@@ -181,7 +192,7 @@
end
-- Count the number of sheets that don't need input till the first that does.
- local counter = noInputSheetCounter()
+ local counter = noInputSheetIndex()
-- Resume control if the last (non-noInput) menu is hidden
if counter == 0 then
orxonox.HumanController:resumeControl()
@@ -203,15 +214,15 @@
-- If the InGameConsole is active, ignore the ESC command.
if bInGameConsoleClosed == true then
- bInGameConsoleClosed = falses
+ bInGameConsoleClosed = false
return
end
-- Count the number of sheets that don't need input till the first that does.
- local counter = noInputSheetCounter()
+ local counter = noInputSheetIndex()
-- If the first sheet that needs input is the MainMenu.
- if counter == 1 and activeMenuSheets[1].sheet.name == "MainMenu" then
+ if noInputSheetCounter() == 1 and activeMenuSheets[counter].sheet.name == "MainMenu" then
orxonox.execute("exit")
-- If there is at least one sheet that needs input.
elseif counter > 0 then
@@ -225,6 +236,14 @@
local we = tolua.cast(e, "CEGUI::KeyEventArgs")
local sheet = activeMenuSheets[activeMenuSheets.size]
code = tostring(we.scancode)
+ -- Some preprocessing
+ if not mainMenuLoaded and not sheet.bNoInput then
+ if code == "1" then
+ keyESC()
+ elseif code == "0"then
+ orxonox.CommandExecutor:execute("openConsole")
+ end
+ end
sheet.sheet:onKeyPressed()
end
@@ -232,11 +251,23 @@
guiMgr:setBackgroundImage(imageSet, imageName)
end
+function noInputSheetIndex()
+ -- Count the number of sheets that don't need input till the first that does.
+ local index = activeMenuSheets.size
+ while index > 0 and activeMenuSheets[index].bNoInput do
+ cout(0, activeMenuSheets[index].sheet.name)
+ index = index - 1
+ end
+ return index
+end
+
function noInputSheetCounter()
- -- Count the number of sheets that don't need input till the first that does.
+ -- Count the number of sheets that do need input.
local counter = activeMenuSheets.size
- while counter > 0 and activeMenuSheets[counter].bNoInput do
- counter = counter - 1
+ for i = 1,activeMenuSheets.size do
+ if activeMenuSheets[i].bNoInput then
+ counter = counter - 1
+ end
end
return counter
end
More information about the Orxonox-commit
mailing list