Index: code/branches/gamestate/data/gui/scripts/AudioMenu.lua
===================================================================
--- code/branches/gamestate/data/gui/scripts/AudioMenu.lua	(revision 6619)
+++ code/branches/gamestate/data/gui/scripts/AudioMenu.lua	(revision 6621)
@@ -1,11 +1,5 @@
 -- AudioMenu.lua
 
-BasicGUI = require("BasicGUI")
-local P = BasicGUI:new("AudioMenu")
-if _REQUIREDNAME == nil then
-    AudioMenu = P
-else
-    _G[_REQUIREDNAME] = P
-end
+local P = createSheet("AudioMenu")
 
 function P:init()
Index: code/branches/gamestate/data/gui/scripts/BasicGUI.lua
===================================================================
--- code/branches/gamestate/data/gui/scripts/BasicGUI.lua	(revision 6619)
+++ code/branches/gamestate/data/gui/scripts/BasicGUI.lua	(revision 6621)
@@ -1,10 +1,6 @@
--- gui.lua
+-- BasicGUI.lua
 
 local P = {}
-if _REQUIREDNAME == nil then
-    BasicGUI = P
-else
-    _G[_REQUIREDNAME] = P
-end
+_G[_REQUIREDNAME or "BasicGUI"] = P
 
 -- useless, even wrong? P is the class, not the object..
@@ -27,5 +23,6 @@
 end
 
--- Override this function if you need to
+-- Override this function if you want to change one of the three input parameters:
+-- showCursor = true, useKeyboard = true and blockJoyStick = false
 -- But don't forget to stick to the naming convention ("GUI_" .. self.filename)
 function P:createInputState()
Index: code/branches/gamestate/data/gui/scripts/ControlsMenu.lua
===================================================================
--- code/branches/gamestate/data/gui/scripts/ControlsMenu.lua	(revision 6619)
+++ code/branches/gamestate/data/gui/scripts/ControlsMenu.lua	(revision 6621)
@@ -1,11 +1,5 @@
 -- ControlsMenu.lua
 
-BasicGUI = require("BasicGUI")
-local P = BasicGUI:new("ControlsMenu")
-if _REQUIREDNAME == nil then
-    ControlsMenu = P
-else
-    _G[_REQUIREDNAME] = P
-end
+local P = createSheet("ControlsMenu")
 
 function P.ControlsMouseControlsButton_clicked(e)
Index: code/branches/gamestate/data/gui/scripts/CreditsMenu.lua
===================================================================
--- code/branches/gamestate/data/gui/scripts/CreditsMenu.lua	(revision 6619)
+++ code/branches/gamestate/data/gui/scripts/CreditsMenu.lua	(revision 6621)
@@ -1,11 +1,8 @@
 -- CreditsMenu.lua
 
-BasicGUI = require("BasicGUI")
-local P = BasicGUI:new("CreditsMenu")
-if _REQUIREDNAME == nil then
-    CreditsMenu = P
-else
-    _G[_REQUIREDNAME] = P
-end
+local sheetName = _REQUIREDNAME or "CreditsMenu"
+-- Create object of type BasicGUI and make it global
+local P = require("BasicGUI"):new(sheetName)
+_G[sheetName] = P
 
 function P.CreditsBackButton_clicked(e)
Index: code/branches/gamestate/data/gui/scripts/DecisionPopup.lua
===================================================================
--- code/branches/gamestate/data/gui/scripts/DecisionPopup.lua	(revision 6619)
+++ code/branches/gamestate/data/gui/scripts/DecisionPopup.lua	(revision 6621)
@@ -1,11 +1,5 @@
 -- DecisionPopup.lua
 
-BasicGUI = require("BasicGUI")
-local P = BasicGUI:new("DecisionPopup")
-if _REQUIREDNAME == nil then
-    DecisionPopup = P
-else
-    _G[_REQUIREDNAME] = P
-end
+local P = createSheet("DecisionPopup")
 
 function P.setCallback(functionPtr)
Index: code/branches/gamestate/data/gui/scripts/GUITools.lua
===================================================================
--- code/branches/gamestate/data/gui/scripts/GUITools.lua	(revision 6619)
+++ code/branches/gamestate/data/gui/scripts/GUITools.lua	(revision 6621)
@@ -1,2 +1,9 @@
+function createSheet(sheetName)
+    -- Create object of type BasicGUI and make it global
+    local sheet = require("BasicGUI"):new(sheetName)
+    _G[sheetName] = sheet
+    return sheet
+end
+
 function openDecisionPopup( text, callbackPtr )
     showGUI("DecisionPopup", false, true)
Index: code/branches/gamestate/data/gui/scripts/GameplayMenu.lua
===================================================================
--- code/branches/gamestate/data/gui/scripts/GameplayMenu.lua	(revision 6619)
+++ code/branches/gamestate/data/gui/scripts/GameplayMenu.lua	(revision 6621)
@@ -1,11 +1,5 @@
 -- GameplayMenu.lua
 
-BasicGUI = require("BasicGUI")
-local P = BasicGUI:new("GameplayMenu")
-if _REQUIREDNAME == nil then
-    GameplayMenu = P
-else
-    _G[_REQUIREDNAME] = P
-end
+local P = createSheet("GameplayMenu")
 
 function P:init()
Index: code/branches/gamestate/data/gui/scripts/GraphicsMenu.lua
===================================================================
--- code/branches/gamestate/data/gui/scripts/GraphicsMenu.lua	(revision 6619)
+++ code/branches/gamestate/data/gui/scripts/GraphicsMenu.lua	(revision 6621)
@@ -1,11 +1,5 @@
 -- GraphicsMenu.lua
 
-BasicGUI = require("BasicGUI")
-local P = BasicGUI:new("GraphicsMenu")
-if _REQUIREDNAME == nil then
-    GraphicsMenu = P
-else
-    _G[_REQUIREDNAME] = P
-end
+local P = createSheet("GraphicsMenu")
 
 function P:init()
Index: code/branches/gamestate/data/gui/scripts/InGameMenu.lua
===================================================================
--- code/branches/gamestate/data/gui/scripts/InGameMenu.lua	(revision 6619)
+++ code/branches/gamestate/data/gui/scripts/InGameMenu.lua	(revision 6621)
@@ -1,11 +1,5 @@
 -- InGameMenu.lua
 
-BasicGUI = require("BasicGUI")
-local P = BasicGUI:new("InGameMenu")
-if _REQUIREDNAME == nil then
-    InGameMenu = P
-else
-    _G[_REQUIREDNAME] = P
-end
+local P = createSheet("InGameMenu")
 
 -- events for ingamemenu
Index: code/branches/gamestate/data/gui/scripts/InfoPopup.lua
===================================================================
--- code/branches/gamestate/data/gui/scripts/InfoPopup.lua	(revision 6619)
+++ code/branches/gamestate/data/gui/scripts/InfoPopup.lua	(revision 6621)
@@ -1,12 +1,5 @@
 -- InfoPopup.lua
 
-BasicGUI = require("BasicGUI")
-local P = BasicGUI:new("InfoPopup")
-
-if _REQUIREDNAME == nil then
-    InfoPopup = P
-else
-    _G[_REQUIREDNAME] = P
-end
+local P = createSheet("InfoPopup")
 
 function P.execute(functionPtr, arguments)
Index: code/branches/gamestate/data/gui/scripts/KeyBindMenu.lua
===================================================================
--- code/branches/gamestate/data/gui/scripts/KeyBindMenu.lua	(revision 6619)
+++ code/branches/gamestate/data/gui/scripts/KeyBindMenu.lua	(revision 6621)
@@ -1,12 +1,5 @@
 -- KeyBindMenu.lua
 
-BasicGUI = require("BasicGUI")
-local P = BasicGUI:new("KeyBindMenu")
-
-if _REQUIREDNAME == nil then
-    KeyBindMenu = P
-else
-    _G[_REQUIREDNAME] = P
-end
+local P = createSheet("KeyBindMenu")
 
 function P:init()
Index: code/branches/gamestate/data/gui/scripts/MainMenu.lua
===================================================================
--- code/branches/gamestate/data/gui/scripts/MainMenu.lua	(revision 6619)
+++ code/branches/gamestate/data/gui/scripts/MainMenu.lua	(revision 6621)
@@ -1,11 +1,5 @@
 -- MainMenu.lua
 
-BasicGUI = require("BasicGUI")
-local P = BasicGUI:new("MainMenu")
-if _REQUIREDNAME == nil then
-    MainMenu = P
-else
-    _G[_REQUIREDNAME] = P
-end
+local P = createSheet("MainMenu")
 
 -- events for MainMenu
Index: code/branches/gamestate/data/gui/scripts/MouseControlsMenu.lua
===================================================================
--- code/branches/gamestate/data/gui/scripts/MouseControlsMenu.lua	(revision 6619)
+++ code/branches/gamestate/data/gui/scripts/MouseControlsMenu.lua	(revision 6621)
@@ -1,11 +1,5 @@
 -- MouseControlsMenu.lua
 
-BasicGUI = require("BasicGUI")
-local P = BasicGUI:new("MouseControlsMenu")
-if _REQUIREDNAME == nil then
-    MouseControlsMenu = P
-else
-    _G[_REQUIREDNAME] = P
-end
+local P = createSheet("MouseControlsMenu")
 
 function P:init()
Index: code/branches/gamestate/data/gui/scripts/MultiplayerMenu.lua
===================================================================
--- code/branches/gamestate/data/gui/scripts/MultiplayerMenu.lua	(revision 6619)
+++ code/branches/gamestate/data/gui/scripts/MultiplayerMenu.lua	(revision 6621)
@@ -1,11 +1,5 @@
 -- MultiplayerMenu.lua
 
-BasicGUI = require("BasicGUI")
-local P = BasicGUI:new("MultiplayerMenu")
-if _REQUIREDNAME == nil then
-    MultiplayerMenu = P
-else
-    _G[_REQUIREDNAME] = P
-end
+local P = createSheet("MultiplayerMenu")
 
 function P:init()
Index: code/branches/gamestate/data/gui/scripts/MultiplayerOptionsMenu.lua
===================================================================
--- code/branches/gamestate/data/gui/scripts/MultiplayerOptionsMenu.lua	(revision 6619)
+++ code/branches/gamestate/data/gui/scripts/MultiplayerOptionsMenu.lua	(revision 6621)
@@ -1,11 +1,5 @@
 -- MultiplayerOptionsMenu.lua
 
-BasicGUI = require("BasicGUI")
-local P = BasicGUI:new("MultiplayerOptionsMenu")
-if _REQUIREDNAME == nil then
-    MultiplayerOptionsMenu = P
-else
-    _G[_REQUIREDNAME] = P
-end
+local P = createSheet("MultiplayerOptionsMenu")
 
 function P.MultiplayerOptionsBackButton_clicked(e)
Index: code/branches/gamestate/data/gui/scripts/PickupInventory.lua
===================================================================
--- code/branches/gamestate/data/gui/scripts/PickupInventory.lua	(revision 6619)
+++ code/branches/gamestate/data/gui/scripts/PickupInventory.lua	(revision 6621)
@@ -1,11 +1,5 @@
 -- PickupInventory.lua
 
-BasicGUI = require("BasicGUI")
-local P = BasicGUI:new("PickupInventory")
-if _REQUIREDNAME == nil then
-    PickupInventory = P
-else
-    _G[_REQUIREDNAME] = P
-end
+local P = createSheet("PickupInventory")
 
 P.lastEquipmentCount_ = 0
Index: code/branches/gamestate/data/gui/scripts/QuestGUI.lua
===================================================================
--- code/branches/gamestate/data/gui/scripts/QuestGUI.lua	(revision 6619)
+++ code/branches/gamestate/data/gui/scripts/QuestGUI.lua	(revision 6621)
@@ -1,9 +1,5 @@
-gui = require("BasicGUI")
-local P = BasicGUI:new("QuestGUI")
-if _REQUIREDNAME == nil then
-    QuestGUI = P
-else
-    _G[_REQUIREDNAME] = P
-end
+-- QuestGUI.lua
+
+local P = createSheet("QuestGUI")
 
 function P:show()
Index: code/branches/gamestate/data/gui/scripts/SettingsMenu.lua
===================================================================
--- code/branches/gamestate/data/gui/scripts/SettingsMenu.lua	(revision 6619)
+++ code/branches/gamestate/data/gui/scripts/SettingsMenu.lua	(revision 6621)
@@ -1,11 +1,5 @@
 -- SettingsMenu.lua
 
-BasicGUI = require("BasicGUI")
-local P = BasicGUI:new("SettingsMenu")
-if _REQUIREDNAME == nil then
-    SettingsMenu = P
-else
-    _G[_REQUIREDNAME] = P
-end
+local P = createSheet("SettingsMenu")
 
 function P.SettingsGameplayButton_clicked(e)
Index: code/branches/gamestate/data/gui/scripts/SingleplayerMenu.lua
===================================================================
--- code/branches/gamestate/data/gui/scripts/SingleplayerMenu.lua	(revision 6619)
+++ code/branches/gamestate/data/gui/scripts/SingleplayerMenu.lua	(revision 6621)
@@ -1,11 +1,5 @@
 -- SingleplayerMenu.lua
 
-BasicGUI = require("BasicGUI")
-local P = BasicGUI:new("SingleplayerMenu")
-if _REQUIREDNAME == nil then
-    SingleplayerMenu = P
-else
-    _G[_REQUIREDNAME] = P
-end
+local P = createSheet("SingleplayerMenu")
 
 function P:init()
