Changeset 6718 for code/branches/gamestates2
- Timestamp:
- Apr 13, 2010, 3:55:30 PM (15 years ago)
- Location:
- code/branches/gamestates2/data
- Files:
-
- 2 added
- 20 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
code/branches/gamestates2/data/gui/scripts/AudioMenu.lua
r6704 r6718 1 1 -- AudioMenu.lua 2 2 3 local P = create Sheet("AudioMenu")3 local P = createMenuSheet("AudioMenu") 4 4 5 5 function P.init() -
code/branches/gamestates2/data/gui/scripts/ControlsMenu.lua
r6704 r6718 1 1 -- ControlsMenu.lua 2 2 3 local P = create Sheet("ControlsMenu")3 local P = createMenuSheet("ControlsMenu") 4 4 5 5 function P.ControlsMouseControlsButton_clicked(e) -
code/branches/gamestates2/data/gui/scripts/CreditsMenu.lua
r6704 r6718 1 1 -- CreditsMenu.lua 2 2 3 local P = create Sheet("CreditsMenu")3 local P = createMenuSheet("CreditsMenu") 4 4 5 5 function P.CreditsBackButton_clicked(e) -
code/branches/gamestates2/data/gui/scripts/DecisionPopup.lua
r6662 r6718 1 1 -- DecisionPopup.lua 2 2 3 local P = create Sheet("DecisionPopup")3 local P = createMenuSheet("DecisionPopup") 4 4 5 5 function P.setCallback(functionPtr) -
code/branches/gamestates2/data/gui/scripts/GUISheet.lua
r6704 r6718 1 -- BasicGUI.lua1 -- GUISheet.lua 2 2 3 3 local P = {} 4 _G[_REQUIREDNAME or "BasicGUI"] = P 4 _G[_REQUIREDNAME or "GUISheet"] = P 5 P.__index = P 5 6 6 -- useless, even wrong? P is the class, not the object.. 7 P.overlay = nil 8 9 -- constructor of the GUI 10 function P:new(_name, _gui, _visible) 11 local newElement = { 12 name = _name, 13 gui = _gui, 14 visible = _visible or false 15 } or {} 16 setmetatable(newElement, self) -- connects new element with class 17 self.__index = self 18 return newElement 7 -- Don't use directly --> use HUDSheet.new or MenuSheet.new 8 function P.new(_name) 9 local newSheet = { name = _name } 10 setmetatable(newSheet, P) 11 return newSheet 19 12 end 20 13 21 -- Override this function if you need to 14 -- Override this function if you need to do work on load 15 -- TODO: rename to onLoad 22 16 function P:init() 23 end24 25 -- Override this function if you want to change one of the three input parameters:26 -- showCursor = true, useKeyboard = true and blockJoyStick = false27 -- But don't forget to stick to the naming convention ("GUI_" .. self.name)28 function P:createInputState()29 self.inputState = guiMgr:createInputState("GUI_" .. self.name)30 17 end 31 18 … … 33 20 function P:hide() 34 21 self.window:hide() 35 self. visible = false22 self.bVisible = false 36 23 end 37 24 … … 39 26 function P:show() 40 27 self.window:show() 41 self. visible = true28 self.bVisible = true 42 29 end 43 30 44 31 function P:load() 32 -- Load the layout that describes the sheet 45 33 self.window = winMgr:loadWindowLayout(self.name .. ".layout") 46 self:createInputState() 34 if self.window == nil then 35 error("Could not load layout file for GUI sheet '"..self.name.."'") 36 end 37 -- Hide it at first 38 self:hide() 39 -- Allow sheets to do some work upon loading 47 40 self:init() 48 41 return self -
code/branches/gamestates2/data/gui/scripts/GUITools.lua
r6666 r6718 1 function createSheet(sheetName) 2 -- Create object of type BasicGUI and make it global 3 local basicGUI = require("BasicGUI") 4 if basicGUI == nil then 5 error("Loading BasicGUI.lua failed") 6 end 7 local sheet = basicGUI:new(sheetName) 8 _G[sheetName] = sheet 1 -- Returns a new menu sheet 2 -- See MenuSheet.new for details about the parameters 3 function createMenuSheet(name, bHidePrevious, tShowCursor, tUseKeyboard, bBlockJoyStick) 4 local sheet = require("MenuSheet").new(name, bHidePrevious, tShowCursor, tUseKeyboard, bBlockJoyStick) 5 _G[sheet.name] = sheet -- Global access required because of the event handlers 6 return sheet 7 end 8 9 -- Returns a new HUD sheet 10 function createHUDSheet(name) 11 local sheet = require("HUDSheet").new(name) 12 _G[sheet.name] = sheet -- Global access required because of the event handlers 9 13 return sheet 10 14 end -
code/branches/gamestates2/data/gui/scripts/GameplayMenu.lua
r6704 r6718 1 1 -- GameplayMenu.lua 2 2 3 local P = create Sheet("GameplayMenu")3 local P = createMenuSheet("GameplayMenu") 4 4 5 5 function P.init() -
code/branches/gamestates2/data/gui/scripts/GraphicsMenu.lua
r6704 r6718 1 1 -- GraphicsMenu.lua 2 2 3 local P = create Sheet("GraphicsMenu")3 local P = createMenuSheet("GraphicsMenu") 4 4 5 5 function P.init() -
code/branches/gamestates2/data/gui/scripts/InGameMenu.lua
r6662 r6718 1 1 -- InGameMenu.lua 2 2 3 local P = create Sheet("InGameMenu")3 local P = createMenuSheet("InGameMenu") 4 4 5 5 -- events for ingamemenu -
code/branches/gamestates2/data/gui/scripts/InfoPopup.lua
r6704 r6718 1 1 -- InfoPopup.lua 2 2 3 local P = create Sheet("InfoPopup")3 local P = createMenuSheet("InfoPopup") 4 4 5 5 function P.execute(functionPtr, arguments) -
code/branches/gamestates2/data/gui/scripts/InitialiseGUI.lua
r6671 r6718 30 30 31 31 local loadedSheets = {} 32 local activeMenuSheets = {size = 0, topSheet = nil}33 --activeHUDSheets = {size = 0, topSheet = nil}32 local activeMenuSheets = {size = 0, topSheetTuple = nil} 33 --activeHUDSheets = {size = 0, topSheetTuple = nil} 34 34 local root = nil 35 35 … … 51 51 -- Load the sheet 52 52 sheet = require(name) 53 if sheet == nil then54 return55 end56 53 sheet:load() 57 54 loadedSheets[name] = sheet 58 -- Hide new GUI as we do not want to show it accidentally59 sheet:hide()60 55 end 61 56 return sheet … … 80 75 81 76 -- ? 82 function showGUI(name, bHidePrevious, bShowCursor, ptr) 83 gui = showGUI(name, bHidePrevious, bShowCursor) 84 gui.overlay = ptr 77 function showGUI(name, bHidePrevious, ptr) 78 local sheet = showGUI(name, bHidePrevious) 79 sheet.overlay = ptr 80 return sheet 85 81 end 86 82 87 83 -- Shows the specified menu sheet and loads it if neccessary 88 function showGUI(name, bHidePrevious, bShowCursor) 89 -- Handle default value for bShowCursor 90 if bShowCursor == nil then 91 if activeMenuSheets.size > 0 then 92 bShowCursor = activeMenuSheets.topSheet.bShowCursor 93 else 94 bShowCursor = true 95 end 84 function showGUI(name, bHidePrevious) 85 -- Get sheet (or load it) 86 local menuSheet = loadSheet(name) 87 if not menuSheet then 88 return nil 89 end 90 91 -- Use sheet's value if nil was provided 92 if bHidePrevious == nil then 93 bHidePrevious = menuSheet.bHidePrevious 94 assert(bHidePrevious ~= nil) 96 95 end 97 96 … … 101 100 end 102 101 103 if not root then104 setBackground("")105 end106 107 -- Get sheet (or load it)108 local menuSheet = loadSheet(name)109 if not menuSheet then110 return111 end112 113 -- Add sheet to the root window114 root:addChildWindow(menuSheet.window)115 116 -- Pause game control if this is the first menu to be displayed117 -- HUGE HACK?118 if activeMenuSheets.size == 0 then119 orxonox.HumanController:pauseControl()120 end121 122 -- Handle input distribution123 orxonox.InputManager:getInstance():enterState(menuSheet.inputState)124 125 if bShowCursor then126 showCursor()127 else128 hideCursor()129 end130 131 102 -- Add the sheet in a tuple of additional information 132 103 local sheetTuple = 133 104 { 134 ["menuSheet"] = menuSheet, 135 ["name"] = name, 136 ["bShowCursor"] = bShowCursor, 105 ["sheet"] = menuSheet, 137 106 ["bHidePrevious"] = bHidePrevious 138 107 } … … 140 109 activeMenuSheets[name] = sheetTuple -- name access 141 110 activeMenuSheets.size = activeMenuSheets.size + 1 142 activeMenuSheets.topSheet = sheetTuple 111 activeMenuSheets.topSheetTuple = sheetTuple 112 113 if not root then 114 setBackground("") 115 end 116 117 -- Add sheet to the root window 118 root:addChildWindow(menuSheet.window) 119 120 -- Pause game control if this is the first menu to be displayed 121 -- HUGE HACK? 122 if activeMenuSheets.size == 0 then 123 orxonox.HumanController:pauseControl() 124 end 125 126 -- Handle input distribution 127 orxonox.InputManager:getInstance():enterState(menuSheet.inputState) 128 129 -- Only change cursor situation if menuSheet.tShowCursor ~= TriBool.Dontcare 130 if menuSheet.tShowCursor == TriBool.True then 131 showCursor() 132 elseif menuSheet.tShowCursor == TriBool.False then 133 hideCursor() 134 end 143 135 144 136 -- Hide all previous sheets if necessary 145 137 if bHidePrevious then 146 138 for i = 1, activeMenuSheets.size - 1 do 147 activeMenuSheets[i]. menuSheet:hide()139 activeMenuSheets[i].sheet:hide() 148 140 end 149 141 end 150 142 151 143 menuSheet:show() 144 152 145 return menuSheet 153 146 end … … 160 153 161 154 -- Hide the sheet 162 sheetTuple. menuSheet:hide()155 sheetTuple.sheet:hide() 163 156 164 157 -- Show sheets that were hidden by the sheet to be removed 165 158 local i = activeMenuSheets.size 166 159 -- Only do something if all sheets on top of sheetTuple 167 -- have bHidePrevious == false and sheetTuple.bHidePrevious == true160 -- have bHidePrevious == true and sheetTuple.bHidePrevious == true 168 161 while i > 0 do 169 if activeMenuSheets[i].bHidePrevious == truethen162 if activeMenuSheets[i].bHidePrevious then 170 163 if activeMenuSheets[i] == sheetTuple then 171 164 i = i - 1 172 165 while i > 0 do 173 activeMenuSheets[i]. menuSheet:show()174 if activeMenuSheets[i].bHidePrevious == truethen166 activeMenuSheets[i].sheet:show() 167 if activeMenuSheets[i].bHidePrevious then 175 168 break 176 169 end … … 184 177 185 178 -- Remove sheet with its tuple from the table 186 root:removeChildWindow(sheetTuple. menuSheet.window)179 root:removeChildWindow(sheetTuple.sheet.window) 187 180 table.remove(activeMenuSheets, table.findIndex(activeMenuSheets, sheetTuple)) 188 181 activeMenuSheets[name] = nil 189 182 activeMenuSheets.size = activeMenuSheets.size - 1 190 activeMenuSheets.topSheet = activeMenuSheets[activeMenuSheets.size]183 activeMenuSheets.topSheetTuple = activeMenuSheets[activeMenuSheets.size] 191 184 192 185 -- Leave the input state 193 orxonox.InputManager:getInstance():leaveState(sheetTuple. menuSheet.inputState)186 orxonox.InputManager:getInstance():leaveState(sheetTuple.sheet.inputState) 194 187 195 -- See whether to show or hide cursor 196 if activeMenuSheets.size > 0 and activeMenuSheets.topSheet.bShowCursor then 188 -- CURSOR SHOWING 189 local i = activeMenuSheets.size 190 -- Find top most sheet that doesn't have tShowCusor == TriBool.Dontcare 191 while i > 0 and activeMenuSheets[i].sheet.tShowCursor == TriBool.Dontcare do 192 i = i - 1 193 end 194 if i > 0 and activeMenuSheets[i].sheet.tShowCursor == TriBool.True then 197 195 showCursor() 198 196 else … … 210 208 function hideAllGUIs() 211 209 while activeMenuSheets.size ~= 0 do 212 hideGUI(activeMenuSheets.topSheet .name)210 hideGUI(activeMenuSheets.topSheetTuple.sheet.name) 213 211 end 214 212 end … … 216 214 function keyESC() 217 215 -- HUGE, very HUGE hacks! 218 if activeMenuSheets.size == 1 and activeMenuSheets[1]. name == "MainMenu" then216 if activeMenuSheets.size == 1 and activeMenuSheets[1].sheet.name == "MainMenu" then 219 217 orxonox.execute("exit") 220 218 elseif activeMenuSheets.size > 0 then 221 orxonox.execute("hideGUI "..activeMenuSheets.topSheet .name)219 orxonox.execute("hideGUI "..activeMenuSheets.topSheetTuple.sheet.name) 222 220 else 223 221 showGUI("InGameMenu") -
code/branches/gamestates2/data/gui/scripts/KeyBindMenu.lua
r6704 r6718 1 1 -- KeyBindMenu.lua 2 2 3 local P = create Sheet("KeyBindMenu")3 local P = createMenuSheet("KeyBindMenu") 4 4 5 5 function P.init() -
code/branches/gamestates2/data/gui/scripts/MainMenu.lua
r6662 r6718 1 1 -- MainMenu.lua 2 2 3 local P = create Sheet("MainMenu")3 local P = createMenuSheet("MainMenu") 4 4 5 5 -- events for MainMenu -
code/branches/gamestates2/data/gui/scripts/MouseControlsMenu.lua
r6704 r6718 1 1 -- MouseControlsMenu.lua 2 2 3 local P = create Sheet("MouseControlsMenu")3 local P = createMenuSheet("MouseControlsMenu") 4 4 5 5 function P.init() -
code/branches/gamestates2/data/gui/scripts/MultiplayerMenu.lua
r6704 r6718 1 1 -- MultiplayerMenu.lua 2 2 3 local P = create Sheet("MultiplayerMenu")3 local P = createMenuSheet("MultiplayerMenu") 4 4 5 5 function P.init() -
code/branches/gamestates2/data/gui/scripts/MultiplayerOptionsMenu.lua
r6704 r6718 1 1 -- MultiplayerOptionsMenu.lua 2 2 3 local P = create Sheet("MultiplayerOptionsMenu")3 local P = createMenuSheet("MultiplayerOptionsMenu") 4 4 5 5 function P.MultiplayerOptionsBackButton_clicked(e) -
code/branches/gamestates2/data/gui/scripts/PickupInventory.lua
r6662 r6718 1 1 -- PickupInventory.lua 2 2 3 local P = create Sheet("PickupInventory")3 local P = createMenuSheet("PickupInventory") 4 4 5 5 P.lastEquipmentCount_ = 0 -
code/branches/gamestates2/data/gui/scripts/QuestGUI.lua
r6704 r6718 1 1 -- QuestGUI.lua 2 2 3 local P = create Sheet("QuestGUI")3 local P = createMenuSheet("QuestGUI") 4 4 5 5 function P.show() -
code/branches/gamestates2/data/gui/scripts/SettingsMenu.lua
r6704 r6718 1 1 -- SettingsMenu.lua 2 2 3 local P = create Sheet("SettingsMenu")3 local P = createMenuSheet("SettingsMenu") 4 4 5 5 function P.SettingsGameplayButton_clicked(e) -
code/branches/gamestates2/data/gui/scripts/SingleplayerMenu.lua
r6704 r6718 1 1 -- SingleplayerMenu.lua 2 2 3 local P = create Sheet("SingleplayerMenu")3 local P = createMenuSheet("SingleplayerMenu") 4 4 5 5 function P.init() -
code/branches/gamestates2/data/lua/Tools.lua
r6671 r6718 16 16 end 17 17 18 -- Short forms for TriBool 19 TriBool = 20 { 21 True = orxonox.TriBool.True, 22 False = orxonox.TriBool.False, 23 Dontcare = orxonox.TriBool.Dontcarex 24 }
Note: See TracChangeset
for help on using the changeset viewer.