Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5427 for data/media/gui


Ignore:
Timestamp:
Mar 25, 2009, 11:13:58 AM (16 years ago)
Author:
bknecht
Message:

CEGUI code structure is now set. Images are loaded into imagesets(XML), those are loaded via schemes(XML), which are loaded in lua scripts. Each gui should now be able to be loaded via a seperate lua-script which itself loads its own layout(XML).

Location:
data/media/gui
Files:
3 added
2 edited

Legend:

Unmodified
Added
Removed
  • data/media/gui/layouts/MainMenu.layout

    r5414 r5427  
    11<?xml version="1.0" ?>
    22<GUILayout>
    3     <Window Type="DefaultGUISheet" Name="orxonox/RootSheet">
     3    <Window Type="TaharezLook/StaticImage" Name="orxonox/Background">
     4    <Property Name="UnifiedSize" Value="{{1.0,0},{1.0,0}}"/>
     5    <Property Name="Image" Value="set:MainMenuBackground image:Background"/>
     6   
    47        <Window Type="TaharezLook/Button" Name="orxonox/StandaloneButton">
    58            <Property Name="UnifiedPosition" Value="{{0.11,0},{0.3,0}}"/>
     
    811            <Event Name="Clicked" Function="button_standalone_clicked"/>
    912        </Window>
     13       
    1014        <Window Type="TaharezLook/Button" Name="orxonox/DedicatedButton">
    1115            <Property Name="UnifiedPosition" Value="{{0.11,0},{0.376,0}}"/>
     
    1418            <Event Name="Clicked" Function="button_dedicated_clicked"/>
    1519        </Window>
     20       
    1621        <Window Type="TaharezLook/Button" Name="orxonox/ServerButton">
    1722            <Property Name="UnifiedPosition" Value="{{0.11,0},{0.452,0}}"/>
     
    2025            <Event Name="Clicked" Function="button_server_clicked"/>
    2126        </Window>
     27       
    2228        <Window Type="TaharezLook/Button" Name="orxonox/ClientButton">
    2329            <Property Name="UnifiedPosition" Value="{{0.11,0},{0.528,0}}"/>
     
    2632            <Event Name="Clicked" Function="button_client_clicked"/>
    2733        </Window>
     34       
    2835        <Window Type="TaharezLook/Button" Name="orxonox/QuitButton">
    2936            <Property Name="UnifiedPosition" Value="{{0.11,0},{0.528,0}}"/>
     
    3239            <Event Name="Clicked" Function="button_quit_clicked"/>
    3340        </Window>
    34         <Window Type="TaharezLook/Button" Name="orxonox/TestButton">
    35             <Property Name="UnifiedPosition" Value="{{0.11,0},{0.604,0}}"/>
    36             <Property Name="UnifiedSize" Value="{{0.15,0},{0.05,0}}"/>
    37             <Property Name="Text" Value="Hide"/>
    38             <Event Name="Clicked" Function="toggleGUI"/>
    39         </Window>
    4041    </Window>
    4142</GUILayout>
  • data/media/gui/scripts/loadGUI.lua

    r5414 r5427  
    33local logger = CEGUI.Logger:getSingleton()
    44local system = CEGUI.System:getSingleton()
     5local cursor = CEGUI.MouseCursor:getSingleton()
    56
    67schemeMgr:loadScheme("TaharezLookSkin.scheme")
     8-- load scheme with our own images
     9schemeMgr:loadScheme("OrxonoxGUIScheme.scheme")
     10
    711system:setDefaultMouseCursor("TaharezLook", "MouseArrow")
    812system:setDefaultFont("BlueHighway-12")
    913
     14local current = nil
     15local loadedGUIs = {}
     16local showing
     17-- we cannot directly call functions with parameters and so need this as a global variable, which sucks of course
     18filename = ""
     19datapath = "" -- points to media-folder (set after loading the script)
    1020
    11 local mainmenu =  winMgr:loadWindowLayout("MainMenu.layout")
    12 
    13 local backgroundImage = CEGUI.ImagesetManager:getSingleton():createImagesetFromImageFile("GUI/Background", "main_menu_1.jpg")
    14 local background = winMgr:createWindow("TaharezLook/StaticImage", "orxonox/Background")
    15 background:setProperty("FrameEnabled", "set: true")
    16 background:setProperty("BackgroundEnabled", "set: false")
    17 background:setProperty("Image", "set: GUI/Background image:full_image")
    18 
    19 background:addChildWindow(mainmenu)
    20 
    21 
    22 function button_quit_clicked(e)
    23   hideGUI()
    24   orxonox.CommandExecutor:execute("exit")
     21-- function to add a reference to list of reference of loaded GUIs
     22loadedGUIs.addGUI = function (gui)
     23    loadedGUIs[#loadedGUIs+1] = gui
    2524end
    2625
    27 function button_standalone_clicked(e)
    28   orxonox.CommandExecutor:execute("selectGameState standalone")
    29   hideGUI()
     26-- function which returns a GUI by name
     27loadedGUIs.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
    3034end
    3135
    32 function button_server_clicked(e)
    33   orxonox.CommandExecutor:execute("selectGameState server")
    34   hideGUI()
     36-- loads the GUI with the specified filename
     37-- be sure to set the global variable "filename" before calling this function
     38function 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
    3555end
    3656
    37 function button_dedicated_clicked(e)
    38   orxonox.CommandExecutor:execute("selectGameState dedicated")
    39   hideGUI()
     57-- shows the specified and loads it if not loaded already
     58-- be sure to set the global variable "filename" before calling this function
     59function 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
    4070end
    41 
    42 function button_client_clicked(e)
    43   orxonox.CommandExecutor:execute("selectGameState client")
    44   hideGUI()
    45 end
    46 
    47 showBackground = true
    48 
    49 function showMainMenu()
    50   if showBackground == true then
    51     system:setGUISheet(background)
    52   else
    53     orxonox.GUIManager:getInstance():testOutput("set new Menu")
    54     system:setGUISheet(mainmenu)
    55   end
    56   return 0;
    57 end
    58 
    59 showing = true
    6071
    6172function toggleGUI()
    6273    if showing == true then
    63         mainmenu:hide()
     74        current:hide()
     75        cursor:hide()
    6476        showing = false
    65         orxonox.GUIManager:getInstance():testOutput("hiding Menu")
    6677    else
    67         mainmenu:show()
     78        current:show()
     79        cursor:show()
    6880        showing = true
    69         orxonox.GUIManager:getInstance():testOutput("showing Menu")
    7081    end
     82    return showing
    7183end
    7284
    7385function hideGUI()
    74   --system:setGUISheet(nil)
    75   --orxonox.GUIManager:getInstance():hideGUI()
     86    current:hide()
     87    showing = false
    7688end
Note: See TracChangeset for help on using the changeset viewer.