Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5428 for data/media


Ignore:
Timestamp:
Mar 25, 2009, 3:17:07 PM (16 years ago)
Author:
rgrieder
Message:

Fixed all branches and the trunk (except for gui of course).

PLEASE NEVER MAKE ANY BREAKING CHANGES IN THE MEDIA REPOSITORY. Always only modify slightly or extend.
There is a thread in the forum that addresses this problem:
https://forum.orxonox.net/viewtopic.php?f=8&t=337

Location:
data/media/gui/scripts
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • data/media/gui/scripts/loadGUI.lua

    r5427 r5428  
    33local logger = CEGUI.Logger:getSingleton()
    44local system = CEGUI.System:getSingleton()
    5 local cursor = CEGUI.MouseCursor:getSingleton()
    65
    76schemeMgr:loadScheme("TaharezLookSkin.scheme")
    8 -- load scheme with our own images
    9 schemeMgr:loadScheme("OrxonoxGUIScheme.scheme")
    10 
    117system:setDefaultMouseCursor("TaharezLook", "MouseArrow")
    128system:setDefaultFont("BlueHighway-12")
    139
    14 local current = nil
    15 local loadedGUIs = {}
    16 local showing
    17 -- we cannot directly call functions with parameters and so need this as a global variable, which sucks of course
    18 filename = ""
    19 datapath = "" -- points to media-folder (set after loading the script)
    2010
    21 -- function to add a reference to list of reference of loaded GUIs
    22 loadedGUIs.addGUI = function (gui)
    23     loadedGUIs[#loadedGUIs+1] = gui
     11local rootSheet = winMgr:createWindow("DefaultGUISheet", "orxonox/Sheet")
     12
     13local leftOffset = 0.11
     14local topOffset  = 0.3
     15local distance   = 0.076
     16local index      = 0
     17
     18local standalone = winMgr:createWindow("TaharezLook/Button", "orxonox/StandaloneButton")
     19standalone:setText("Standalone")
     20standalone:setSize(CEGUI.UVector2(CEGUI.UDim(0.15, 0), CEGUI.UDim(0.05, 0)))
     21standalone:setPosition(CEGUI.UVector2(CEGUI.UDim(leftOffset, 0), CEGUI.UDim(topOffset + index * distance, 0)))
     22standalone:subscribeEvent("Clicked","button_standalone_clicked")
     23index = index + 1
     24
     25local dedicated = winMgr:createWindow("TaharezLook/Button", "orxonox/DedicatedButton")
     26dedicated:setText("Dedicated")
     27dedicated:setSize(CEGUI.UVector2(CEGUI.UDim(0.15, 0), CEGUI.UDim(0.05, 0)))
     28dedicated:setPosition(CEGUI.UVector2(CEGUI.UDim(leftOffset, 0), CEGUI.UDim(topOffset + index * distance, 0)))
     29dedicated:subscribeEvent("Clicked","button_dedicated_clicked")
     30index = index + 1
     31
     32local server = winMgr:createWindow("TaharezLook/Button", "orxonox/ServerButton")
     33server:setText("Server")
     34server:setSize(CEGUI.UVector2(CEGUI.UDim(0.15, 0), CEGUI.UDim(0.05, 0)))
     35server:setPosition(CEGUI.UVector2(CEGUI.UDim(leftOffset, 0), CEGUI.UDim(topOffset + index * distance, 0)))
     36server:subscribeEvent("Clicked","button_server_clicked")
     37index = index + 1
     38
     39local client = winMgr:createWindow("TaharezLook/Button", "orxonox/ClientButton")
     40client:setText("Client")
     41client:setSize(CEGUI.UVector2(CEGUI.UDim(0.15, 0), CEGUI.UDim(0.05, 0)))
     42client:setPosition(CEGUI.UVector2(CEGUI.UDim(leftOffset, 0), CEGUI.UDim(topOffset + index * distance, 0)))
     43client:subscribeEvent("Clicked","button_client_clicked")
     44index = index + 1
     45
     46local quit = winMgr:createWindow("TaharezLook/Button", "orxonox/QuitButton")
     47quit:setText("Quit")
     48quit:setSize(CEGUI.UVector2(CEGUI.UDim(0.15, 0), CEGUI.UDim(0.05, 0)))
     49quit:setPosition(CEGUI.UVector2(CEGUI.UDim(leftOffset, 0), CEGUI.UDim(topOffset + index * distance, 0)))
     50quit:subscribeEvent("Clicked","button_quit_clicked")
     51index = index + 1
     52
     53local backgroundImage = CEGUI.ImagesetManager:getSingleton():createImagesetFromImageFile("GUI/Background", "main_menu_1.jpg")
     54local background = winMgr:createWindow("TaharezLook/StaticImage", "orxonox/Background")
     55background:setProperty("FrameEnabled", "set: true")
     56background:setProperty("BackgroundEnabled", "set: false")
     57background:setProperty("Image", "set: GUI/Background image:full_image")
     58
     59rootSheet:addChildWindow(quit)
     60rootSheet:addChildWindow(standalone)
     61rootSheet:addChildWindow(server)
     62rootSheet:addChildWindow(dedicated)
     63rootSheet:addChildWindow(client)
     64background:addChildWindow(rootSheet)
     65
     66
     67function button_quit_clicked(e)
     68  hideGUI()
     69  orxonox.CommandExecutor:execute("exit")
    2470end
    2571
    26 -- function which returns a GUI by name
    27 loadedGUIs.getGUIbyName = function (str)
    28     for i = 1, #loadedGUIs, 1 do
    29         if str == loadedGUIs[i].filename then
    30             return loadedGUIs[i]
    31         end
    32     end
    33     return nil
     72function button_standalone_clicked(e)
     73  orxonox.CommandExecutor:execute("selectGameState standalone")
     74  hideGUI()
    3475end
    3576
    36 -- loads the GUI with the specified filename
    37 -- be sure to set the global variable "filename" before calling this function
    38 function loadGUI()
    39     -- check if it already exists
    40     newlyLoaded = loadedGUIs:getGUIbyName(filename)
    41     if newlyLoaded == nil then
    42         dofile(datapath .. "gui/scripts/" .. filename)
    43         newlyLoaded = winMgr:loadWindowLayout(layoutPath)
    44         newlyLoaded.filename = filename
    45         loadedGUIs:addGUI(newlyLoaded)
    46         -- if there has no GUI been loaded yet, set new GUI as current
    47         if #loadedGUIs == 1 then
    48             current = loadedGUIs[1]
    49             showing = false
    50         end
    51         -- hide new GUI as we do not want to show it accidentially
    52         newlyLoaded:hide()
    53     end
    54     return newlyLoaded
     77function button_server_clicked(e)
     78  orxonox.CommandExecutor:execute("selectGameState server")
     79  hideGUI()
    5580end
    5681
    57 -- shows the specified and loads it if not loaded already
    58 -- be sure to set the global variable "filename" before calling this function
    59 function showGUI()
    60     if current == nil or current.filename ~= filename then
    61         current = loadedGUIs.getGUIbyName(filename)
    62         if current == nil then
    63             current = loadGUI(filename)
    64         end
    65         system:setGUISheet(current)
    66     end
    67     current:show()
    68     cursor:show()
    69     showing = true
     82function button_dedicated_clicked(e)
     83  orxonox.CommandExecutor:execute("selectGameState dedicated")
     84  hideGUI()
    7085end
    7186
    72 function toggleGUI()
    73     if showing == true then
    74         current:hide()
    75         cursor:hide()
    76         showing = false
    77     else
    78         current:show()
    79         cursor:show()
    80         showing = true
    81     end
    82     return showing
     87function button_client_clicked(e)
     88  orxonox.CommandExecutor:execute("selectGameState client")
     89  hideGUI()
     90end
     91
     92showBackground = false
     93
     94function showMainMenu()
     95  if showBackground == true then
     96    system:setGUISheet(background)
     97  else
     98    system:setGUISheet(rootSheet)
     99  end
     100  return 0;
    83101end
    84102
    85103function hideGUI()
    86     current:hide()
    87     showing = false
     104  system:setGUISheet(nil)
     105  orxonox.GUIManager:getInstance():hideGUI()
    88106end
Note: See TracChangeset for help on using the changeset viewer.