Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7163 for code/trunk/data/gui


Ignore:
Timestamp:
Aug 11, 2010, 8:55:13 AM (14 years ago)
Author:
dafrick
Message:

Merged presentation3 branch into trunk.

Location:
code/trunk
Files:
14 edited
8 copied

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/data/gui/layouts/MultiplayerMenu.layout

    r6746 r7163  
    1616            <Property Name="VertFormatting" Value="TopAligned" />
    1717            <Property Name="UnifiedAreaRect" Value="{{0.25,0},{0.2875,0},{0.75,0},{0.6375,0}}" />
    18             <Window Type="MenuWidgets/Listbox" Name="orxonox/MultiplayerLevelListbox" >
     18            <Window Type="MenuWidgets/Listbox" Name="orxonox/MultiplayerListbox" >
    1919                <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
    2020                <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.15,0},{0.95,0},{0.8,0}}" />
  • code/trunk/data/gui/layouts/SettingsMenu.layout

    r6746 r7163  
    22
    33<GUILayout >
    4     <Window Type="MenuWidgets/StaticImage" Name="orxonox/SettingsBackground" >
     4    <Window Type="MenuWidgets/StaticImage" Name="orxonox/SettingsMenu/Background" >
    55        <Property Name="InheritsAlpha" Value="False" />
    66        <Property Name="FrameEnabled" Value="False" />
     
    88        <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
    99        <Property Name="BackgroundEnabled" Value="False" />
    10         <Window Type="MenuWidgets/StaticText" Name="orxonox/SettingsWindow" >
     10        <Window Type="MenuWidgets/StaticText" Name="orxonox/SettingsMenu/SettingsWindow" >
    1111            <Property Name="Text" Value="Settings" />
    1212            <Property Name="Alpha" Value="0.8" />
     
    1616            <Property Name="VertFormatting" Value="TopAligned" />
    1717            <Property Name="UnifiedAreaRect" Value="{{0.25,0},{0.3625,0},{0.75,0},{0.6375,0}}" />
    18             <Window Type="MenuWidgets/Button" Name="orxonox/GameplayButton" >
     18            <Window Type="MenuWidgets/Button" Name="orxonox/SettingsMenu/GameplayButton" >
    1919                <Property Name="Text" Value="Gameplay" />
    2020                <Property Name="Disabled" Value="True" />
     
    2323                <Event Name="Clicked" Function="SettingsMenu.SettingsGameplayButton_clicked"/>
    2424            </Window>
    25             <Window Type="MenuWidgets/Button" Name="orxonox/MultiplayerOptionsButton" >
     25            <Window Type="MenuWidgets/Button" Name="orxonox/SettingsMenu/MultiplayerOptionsButton" >
    2626                <Property Name="Text" Value="Multiplayer options" />
    2727                <Property Name="Disabled" Value="True" />
     
    3030                <Event Name="Clicked" Function="SettingsMenu.SettingsMultiplayerOptionsButton_clicked"/>
    3131            </Window>
    32             <Window Type="MenuWidgets/Button" Name="orxonox/ControlsButton" >
     32            <Window Type="MenuWidgets/Button" Name="orxonox/SettingsMenu/ControlsButton" >
    3333                <Property Name="Text" Value="Controls" />
    3434                <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
     
    3636                <Event Name="Clicked" Function="SettingsMenu.SettingsControlsButton_clicked"/>
    3737            </Window>
    38             <Window Type="MenuWidgets/Button" Name="orxonox/GraphicsButton" >
     38            <Window Type="MenuWidgets/Button" Name="orxonox/SettingsMenu/GraphicsButton" >
    3939                <Property Name="Text" Value="Graphics" />
    4040                <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
     
    4242                <Event Name="Clicked" Function="SettingsMenu.SettingsGraphicsButton_clicked"/>
    4343            </Window>
    44             <Window Type="MenuWidgets/Button" Name="orxonox/AudioButton" >
     44            <Window Type="MenuWidgets/Button" Name="orxonox/SettingsMenu/AudioButton" >
    4545                <Property Name="Text" Value="Audio" />
    4646                <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
     
    4848                <Event Name="Clicked" Function="SettingsMenu.SettingsAudioButton_clicked"/>
    4949            </Window>
    50             <Window Type="MenuWidgets/Button" Name="orxonox/ResetSettingsButton" >
    51                 <Property Name="Text" Value="Reset settings" />
    52                 <Property Name="Disabled" Value="True" />
     50            <Window Type="MenuWidgets/Button" Name="orxonox/SettingsMenu/MiscellaneousButton" >
     51                <Property Name="Text" Value="Miscellaneous" />
    5352                <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
    5453                <Property Name="UnifiedAreaRect" Value="{{0.55,0},{0.727272,0},{0.95,0},{0.909090,0}}" />
    55                 <Event Name="Clicked" Function="SettingsMenu.SettingsResetSettingsButton_clicked"/>
     54                <Event Name="Clicked" Function="SettingsMenu.SettingsMiscellaneousButton_clicked"/>
    5655            </Window>
    5756        </Window>
    58         <Window Type="MenuWidgets/Button" Name="orxonox/SettingsBackButton" >
     57        <Window Type="MenuWidgets/Button" Name="orxonox/SettingsMenu/SettingsBackButton" >
    5958            <Property Name="Text" Value="Back" />
    6059            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
  • code/trunk/data/gui/schemes/OrxonoxGUIScheme.scheme

    r6746 r7163  
    66    <Font Name="BlueHighway-10" Filename="bluehighway-10.font" />
    77    <Font Name="BlueHighway-8"  Filename="bluehighway-8.font"  />
     8    <Font Name="Monofur-10"     Filename="Monofur-10.font" />
    89</GUIScheme>
  • code/trunk/data/gui/scripts/GUITools.lua

    r6746 r7163  
    4545    return 0.008*ratio/0.3204
    4646end
     47
     48function getStaticTextWindowHeight(window)
     49    local lookAndFeel = CEGUI.WidgetLookManager:getSingleton():getWidgetLook(window:getLookNFeel())
     50    local formattedArea = lookAndFeel:getNamedArea("WithFrameTextRenderArea"):getArea():getPixelRect(window)
     51    local frameHeight = window:getUnclippedPixelRect():getHeight() - formattedArea:getHeight()
     52    local lines = window:getFont():getFormattedLineCount(window:getText(), formattedArea, CEGUI.WordWrapLeftAligned)
     53    local height = lines * window:getFont():getLineSpacing() + frameHeight
     54    return height
     55end
  • code/trunk/data/gui/scripts/HUDSheet.lua

    • Property svn:eol-style set to native
  • code/trunk/data/gui/scripts/KeyBindMenu.lua

    r6748 r7163  
    1010    table.insert(commandList, "fire 1 | unfire")
    1111    table.insert(commandList, "onpress fire 2")
     12    table.insert(commandList, "onpress fire 3")
    1213    table.insert(commandList, "scale 1 moveFrontBack")
    1314    table.insert(commandList, "scale -1 moveFrontBack")
     
    2829    table.insert(commandList, "OverlayGroup toggleVisibility Debug")
    2930    table.insert(commandList, "OverlayGroup toggleVisibility Stats")
     31    table.insert(commandList, "OrxonoxOverlay toggleVisibility QuestGUI")
     32    table.insert(commandList, "OrxonoxOverlay toggleVisibility PickupInventory")
     33    table.insert(commandList, "startchat")
     34    table.insert(commandList, "startchat_small")
    3035    table.insert(commandList, "mouseLook")
    3136    table.insert(commandList, "pause")
     
    3540    table.insert(nameList, "Secondary Fire")
    3641    table.insert(nameList, "Fire Rocket")
     42    table.insert(nameList, "Fire Alternative Rocket")
    3743    table.insert(nameList, "Accelerate")
    3844    table.insert(nameList, "Break")
     
    5359    table.insert(nameList, "Show Debug")
    5460    table.insert(nameList, "Show Stats")
     61    table.insert(nameList, "Show Quests")
     62    table.insert(nameList, "Show Pickups")
     63    table.insert(nameList, "Show Chat")
     64    table.insert(nameList, "Show small Chat")
    5565    table.insert(nameList, "Look Around")
    5666    table.insert(nameList, "Pause")
     
    170180    end
    171181
    172     pane = tolua.cast(window, "CEGUI::ScrollablePane")
     182    local pane = tolua.cast(window, "CEGUI::ScrollablePane")
    173183    pane:setVerticalStepSize(getScrollingStepSize(window))
    174184end
  • code/trunk/data/gui/scripts/MainMenu.lua

    r6748 r7163  
    66-- events for MainMenu
    77function P.QuickGameTestButton_clicked(e)
     8    hideAllMenuSheets()
    89    orxonox.execute("startGame")
    910end
  • code/trunk/data/gui/scripts/MenuSheet.lua

    • Property svn:eol-style set to native
  • code/trunk/data/gui/scripts/MultiplayerMenu.lua

    r6746 r7163  
    44
    55function P.onLoad()
    6     listbox = winMgr:getWindow("orxonox/MultiplayerLevelListbox")
    7     preselect = orxonox.LevelManager:getInstance():getDefaultLevel()
     6    P.multiplayerMode = "startClient"
     7end
     8
     9function P.onShow()
     10    if P.multiplayerMode == "startClient" then
     11        local window = winMgr:getWindow("orxonox/MultiplayerJoinButton")
     12        local button = tolua.cast(window,"CEGUI::RadioButton")
     13        button:setSelected(true)
     14        P.showServerList()
     15    end
     16    if P.multiplayerMode == "startServer" then
     17        local window = winMgr:getWindow("orxonox/MultiplayerHostButton")
     18        local button = tolua.cast(window,"CEGUI::RadioButton")
     19        button:setSelected(true)
     20        P.showLevelList()
     21    end
     22    if P.multiplayerMode == "startDedicated" then
     23        local window = winMgr:getWindow("orxonox/MultiplayerDedicatedButton")
     24        local button = tolua.cast(window,"CEGUI::RadioButton")
     25        button:setSelected(true)
     26        P.showLevelList()
     27    end
     28end
     29
     30function P.MultiplayerJoinButton_clicked(e)
     31    P.multiplayerMode = "startClient"
     32    P.showServerList()
     33end
     34
     35function P.MultiplayerHostButton_clicked(e)
     36    P.multiplayerMode = "startServer"
     37    P.showLevelList()
     38end
     39
     40function P.MultiplayerDedicatedButton_clicked(e)
     41    P.multiplayerMode = "startDedicated"
     42    P.showLevelList()
     43end
     44
     45function P.MultiplayerStartButton_clicked(e)
     46    local choice = winMgr:getWindow("orxonox/MultiplayerListbox"):getFirstSelectedItem()
     47    if P.multiplayerMode == "startClient" then
     48        if choice then
     49            local client = orxonox.Client:getInstance()
     50            local index = tolua.cast(choice, "CEGUI::ListboxItem"):getID()
     51            client:setDestination( P.serverList[index][2], 55556 )
     52        else
     53            return
     54        end
     55    else
     56        if choice then
     57            orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw")
     58        else
     59            return
     60        end
     61    end
     62    orxonox.execute(P.multiplayerMode)
     63    hideAllMenuSheets()
     64end
     65
     66function P.MultiplayerBackButton_clicked(e)
     67    hideMenuSheet(P.name)
     68end
     69
     70function P.showLevelList()
     71    local listbox = winMgr:getWindow("orxonox/MultiplayerListbox")
     72    CEGUI.toListbox(listbox):resetList()
     73    local preselect = orxonox.LevelManager:getInstance():getDefaultLevel()
    874    orxonox.LevelManager:getInstance():compileAvailableLevelList()
    975    local levelList = {}
     
    1985    end
    2086    table.sort(levelList)
     87    index = 1
    2188    for k,v in pairs(levelList) do
    22         item = CEGUI.createListboxTextItem(v)
     89        local item = CEGUI.createListboxTextItem(v)
    2390        item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
     91        item:setID(index)
     92        index = index + 1
    2493        CEGUI.toListbox(listbox):addItem(item)
    2594        if v .. ".oxw" == preselect then
     
    2796        end
    2897    end
    29     local multiplayerMode = "startClient"
    30     if multiplayerMode == "startClient" then
    31         window = winMgr:getWindow("orxonox/MultiplayerJoinButton")
    32         button = tolua.cast(window,"CEGUI::RadioButton")
    33         button:setSelected(true)
    3498    end
    35     if multiplayerMode == "startServer" then
    36         window = winMgr:getWindow("orxonox/MultiplayerHostButton")
    37         button = tolua.cast(window,"CEGUI::RadioButton")
    38         button:setSelected(true)
     99   
     100function P.showServerList()
     101    local listbox = winMgr:getWindow("orxonox/MultiplayerListbox")
     102    CEGUI.toListbox(listbox):resetList()
     103    local discovery = orxonox.LANDiscovery:getInstance()
     104    discovery:discover()
     105    P.serverList = {}
     106    local index = 0
     107    local servername = ""
     108    local serverip = ""
     109    while true do
     110        servername = discovery:getServerListItemName(index)
     111        if servername == "" then
     112            break
     113        end
     114        serverip = discovery:getServerListItemIP(index)
     115        if serverip == "" then
     116          break
     117        end
     118        table.insert(P.serverList, {servername, serverip})
     119        index = index + 1
    39120    end
    40     if multiplayerMode == "startDedicated" then
    41         window = winMgr:getWindow("orxonox/MultiplayerDedicatedButton")
    42         button = tolua.cast(window,"CEGUI::RadioButton")
    43         button:setSelected(true)
     121    index = 1
     122    for k,v in pairs(P.serverList) do
     123        local item = CEGUI.createListboxTextItem( v[1] .. ": " .. v[2] )
     124        item:setID(index)
     125        index = index + 1
     126        item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
     127        CEGUI.toListbox(listbox):addItem(item)
    44128    end
    45 end
    46 
    47 function P.MultiplayerJoinButton_clicked(e)
    48     multiplayerMode = "startClient"
    49 end
    50 
    51 function P.MultiplayerHostButton_clicked(e)
    52     multiplayerMode = "startServer"
    53 end
    54 
    55 function P.MultiplayerDedicatedButton_clicked(e)
    56     multiplayerMode = "startDedicated"
    57 end
    58 
    59 function P.MultiplayerStartButton_clicked(e)
    60     local choice = winMgr:getWindow("orxonox/MultiplayerLevelListbox"):getFirstSelectedItem()
    61     if choice then
    62         orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw")
    63         orxonox.execute(multiplayerMode)
    64         hideAllMenuSheets()
    65     end
    66 end
    67 
    68 function P.MultiplayerBackButton_clicked(e)
    69     hideMenuSheet(P.name)
    70129end
    71130
  • code/trunk/data/gui/scripts/PickupInventory.lua

    r6906 r7163  
    33local P = createMenuSheet("PickupInventory")
    44
    5 P.carrierList = {}
    65P.wrapper = nil
    76P.detailsWindows = {}
     7P.detailPickups = {}
     8P.pickupsList = {}
     9
     10P.showing = false
     11
     12-- Design parameters
     13P.imageHeight = 50
     14P.detailImageSize = 100
     15P.textHeight = 30
     16P.buttonWidth = 85
    817
    918function P.onLoad()
    10     carrierList = {}
     19    P.wrapper = nil
     20    P.detailsWindows = {}
     21    P.detailPickups = {}
     22    P.pickupsList = {}
    1123end
    1224
    1325function P.onShow()
    1426    P.createInventory()
     27    P.showing = true
    1528end
    1629
    1730function P.onHide()
    18     P.cleanup()
     31    P.showing = false
     32    P.cleanup(true)
    1933end
    2034
    2135function P.update()
    22     P.cleanup()
    23    
     36    if P.showing == false then
     37        return
     38    end
     39
     40    -- Update opened detail windows.
     41    for k,v in pairs(P.detailsWindows) do
     42        if v ~= nil then
     43            local pickup = P.detailPickups[k]
     44            if pickup ~= nil and pickup ~= 0 then
     45                local useButton = winMgr:getWindow("orxonox/PickupInventory/Details" .. k .. "/UseButton")
     46                local dropButton = winMgr:getWindow("orxonox/PickupInventory/Details" .. k .. "/DropButton")
     47                if orxonox.PickupManager:getInstance():isValidPickup(pickup) == false then
     48                    useButton:setEnabled(false)
     49                    dropButton:setEnabled(false)
     50                    P.detailPickups[k] = nil
     51                else
     52                    useButton:setEnabled(true)
     53                    if pickup:isUsed() == true then
     54                        useButton:setText("unuse")
     55                        orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.name .. ".InventoryUseDetailButton_clicked")
     56                        if pickup:isUsable() == false then
     57                            useButton:setEnabled(false)
     58                        end
     59                    else
     60                        useButton:setText("use")
     61                        orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.name .. ".InventoryUnuseDetailButton_clicked")
     62                        if pickup:isUnusable() == false then
     63                            useButton:setEnabled(false)
     64                        end
     65                    end
     66
     67                    if pickup:isPickedUp() == false then
     68                        useButton:setEnabled(false)
     69                        dropButton:setEnabled(false)
     70                        P.detailPickups[k] = nil
     71                    end
     72                end
     73            end
     74        end
     75    end
     76
     77    -- Update main inventory.
     78    P.cleanup(false)
    2479    P.createInventory()
     80    -- TODO: Recover scrolling position
     81   
    2582end
    2683
    2784function P.createInventory()
    2885    local pickupManager = orxonox.PickupManager:getInstance()
    29     local carrier = pickupManager:getPawn()
    3086   
    3187    local root = winMgr:getWindow("orxonox/PickupInventory/Inventory")
     
    3490    root:addChildWindow(P.wrapper)
    3591   
    36     P.carrierList = {}
    37    
    38     --Design parameters:
    39     local space = 15
    40    
    41     P.getCarrierList(carrier)
     92    P.pickupsList = {}
     93
     94    local numPickups = pickupManager:getNumPickups()
     95    local counter = 1
    4296    local offset = 0
    43     for k,v in pairs(P.carrierList) do
    44         local window = P.createCarrierBox(v,k)
     97    while counter <= numPickups do
     98        local pickup = pickupManager:popPickup()
     99        table.insert(P.pickupsList, pickup)
     100        local window = P.createPickupEntry(counter, pickup)
    45101        window:setYPosition(CEGUI.UDim(0,offset))
    46         offset = offset + window:getHeight():asAbsolute(1) + space
     102        offset = offset + window:getHeight():asAbsolute(1)
    47103        P.wrapper:addChildWindow(window)
    48     end
    49 end
    50 
    51 function P.getCarrierList(carrier)
    52 
    53     -- TODO: Test for nil or 0?
    54     if carrier == nil then
    55         return
    56     end
    57    
    58     table.insert(P.carrierList, carrier)
    59    
    60     local numCarriers = orxonox.PickupManager:getInstance():getNumCarrierChildren(carrier)
    61     if numCarriers == 0 then
    62         return
    63     end
    64    
    65     for i=0,numCarriers-1,1 do
    66         local child = orxonox.PickupManager:getInstance():getCarrierChild(i, carrier)
    67         if child ~= nil then
    68             P.getCarrierList(child)
    69         end
    70     end
    71 end
    72 
    73 function P.createCarrierBox(carrier, index)
    74 
    75     local name = "orxonox/PickupInventory/Carrier" .. index
    76    
    77     --Design parameters:
    78     local imageHeight = 50
    79     local textHeight = 30
    80     local horizontalOffset = 20
    81     local buttonWidth = 85
    82    
    83     local offset = 0
    84 
    85     local box = winMgr:createWindow("MenuWidgets/ScrollablePane", name .. "/Box")
    86     box:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horizontalOffset), CEGUI.UDim(0, 0)))
    87     box:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -horizontalOffset), CEGUI.UDim(1, 0)))
    88    
    89     local numPickups = orxonox.PickupManager:getInstance():getNumPickups(carrier)
    90     for i=0,numPickups-1,1 do
    91         local pickup = orxonox.PickupManager:getInstance():getPickupRepresentation(i, carrier)
    92        
    93         local item = winMgr:createWindow("MenuWidgets/StaticText", name .. "/Box/Pickup" .. i)
    94         item:setSize(CEGUI.UVector2(CEGUI.UDim(1, -horizontalOffset), CEGUI.UDim(0, imageHeight)))
    95         item:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horizontalOffset), CEGUI.UDim(0, offset)))
    96         box:addChildWindow(item)
    97         offset = offset + imageHeight+5
    98        
    99         local image = winMgr:createWindow("MenuWidgets/StaticImage", name .. "/Box/Pickup" .. i .. "/Image")
    100         image:setProperty("Image", "set:PickupInventory image:" .. pickup:getInventoryRepresentation())
    101         image:setProperty("BackgroundEnabled", "set:False")
    102         image:setProperty("FrameEnabled", "set:True")
    103         image:setSize(CEGUI.UVector2(CEGUI.UDim(0, imageHeight), CEGUI.UDim(0, imageHeight)))
    104         item:addChildWindow(image)
    105        
    106         local title = winMgr:createWindow("MenuWidgets/StaticText", name .. "/Box/Pickup" .. i .. "/Title")
    107         title:setPosition(CEGUI.UVector2(CEGUI.UDim(0, imageHeight+5), CEGUI.UDim(0, (imageHeight-textHeight)/2)))
    108         title:setSize(CEGUI.UVector2(CEGUI.UDim(0.4, 0), CEGUI.UDim(0, textHeight)))
    109         title:setText(pickup:getPickupName())
    110         title:setProperty("FrameEnabled", "set:False")
    111         item:addChildWindow(title)
    112        
    113         local useButton = winMgr:createWindow("MenuWidgets/Button", name .. "/Box/Pickup" .. i .. "/UseButton")
    114         useButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0.4, imageHeight+10),CEGUI.UDim(0, (imageHeight-textHeight)/2)))
    115         useButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, buttonWidth), CEGUI.UDim(0, textHeight)))
     104        counter = counter + 1
     105    end
     106
     107end
     108
     109function P.createPickupEntry(index, pickup)
     110    local representation = orxonox.PickupManager:getInstance():getPickupRepresentation(pickup)
     111
     112    local name = "orxonox/PickupInventory/Box/Pickup" .. index
     113
     114    local item = winMgr:createWindow("MenuWidgets/StaticText", name)
     115    item:setSize(CEGUI.UVector2(CEGUI.UDim(1, 0), CEGUI.UDim(0, P.imageHeight)))
     116    item:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, 0)))
     117
     118    local image = winMgr:createWindow("MenuWidgets/StaticImage", name .. "/Image")
     119    image:setProperty("Image", "set:PickupInventory image:" .. representation:getInventoryRepresentation())
     120    image:setProperty("BackgroundEnabled", "set:False")
     121    image:setProperty("FrameEnabled", "set:True")
     122    image:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.imageHeight), CEGUI.UDim(0, P.imageHeight)))
     123    item:addChildWindow(image)
     124
     125    local title = winMgr:createWindow("MenuWidgets/StaticText", name .. "/Title")
     126    title:setPosition(CEGUI.UVector2(CEGUI.UDim(0, P.imageHeight+5), CEGUI.UDim(0, (P.imageHeight-P.textHeight)/2)))
     127    title:setSize(CEGUI.UVector2(CEGUI.UDim(0.3, 0), CEGUI.UDim(0, P.textHeight)))
     128    title:setText(representation:getPickupName())
     129    title:setProperty("FrameEnabled", "set:False")
     130    item:addChildWindow(title)
     131
     132    local useButton = winMgr:createWindow("MenuWidgets/Button", name .. "/UseButton")
     133    useButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0.3, P.imageHeight+10),CEGUI.UDim(0, (P.imageHeight-P.textHeight)/2)))
     134    useButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.buttonWidth), CEGUI.UDim(0, P.textHeight)))
     135    if pickup:isUsed() == false then
    116136        useButton:setText("use")
    117137        orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.name .. ".InventoryUseButton_clicked")
    118         item:addChildWindow(useButton)
    119        
    120         local dropButton = winMgr:createWindow("MenuWidgets/Button", name .. "/Box/Pickup" .. i .. "/DropButton")
    121         dropButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0.4, imageHeight+15+buttonWidth),CEGUI.UDim(0, (imageHeight-textHeight)/2)))
    122         dropButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, buttonWidth), CEGUI.UDim(0, textHeight)))
    123         dropButton:setText("drop")
    124         orxonox.GUIManager:subscribeEventHelper(dropButton, "Clicked", P.name .. ".InventoryDropButton_clicked")
    125         item:addChildWindow(dropButton)
    126        
    127         local detailsButton = winMgr:createWindow("MenuWidgets/Button", name .. "/Box/Pickup" .. i .. "/DetailsButton")
    128         detailsButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0.4, imageHeight+20+2*buttonWidth),CEGUI.UDim(0, (imageHeight-textHeight)/2)))
    129         detailsButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, buttonWidth), CEGUI.UDim(0, textHeight)))
    130         detailsButton:setText("details")
    131         orxonox.GUIManager:subscribeEventHelper(detailsButton, "Clicked", P.name .. ".InventoryDetailsButton_clicked")
    132         item:addChildWindow(detailsButton)
    133     end
    134    
    135     box:setHeight(CEGUI.UDim(0,offset))
    136    
    137     return box
    138 end
    139 
    140 function P.cleanup()
     138        if pickup:isUsable() == false then
     139            useButton:setEnabled(false)
     140        end
     141    else
     142        useButton:setText("unuse")
     143        orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.name .. ".InventoryUnuseButton_clicked")
     144        if pickup:isUnusable() == false then
     145            useButton:setEnabled(false)
     146        end
     147    end
     148    item:addChildWindow(useButton)
     149
     150    local dropButton = winMgr:createWindow("MenuWidgets/Button", name .. "/DropButton")
     151    dropButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0.3, P.imageHeight+15+P.buttonWidth),CEGUI.UDim(0, (P.imageHeight-P.textHeight)/2)))
     152    dropButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.buttonWidth), CEGUI.UDim(0, P.textHeight)))
     153    dropButton:setText("drop")
     154    orxonox.GUIManager:subscribeEventHelper(dropButton, "Clicked", P.name .. ".InventoryDropButton_clicked")
     155    item:addChildWindow(dropButton)
     156
     157    local detailsButton = winMgr:createWindow("MenuWidgets/Button", name .. "/DetailsButton")
     158    detailsButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0.3, P.imageHeight+20+2*P.buttonWidth),CEGUI.UDim(0, (P.imageHeight-P.textHeight)/2)))
     159    detailsButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.buttonWidth), CEGUI.UDim(0, P.textHeight)))
     160    detailsButton:setText("details")
     161    orxonox.GUIManager:subscribeEventHelper(detailsButton, "Clicked", P.name .. ".InventoryDetailsButton_clicked")
     162    item:addChildWindow(detailsButton)
     163
     164    return item
     165end
     166
     167function P.cleanup(destroyDetails)
    141168    if P.wrapper ~= nil then
    142169        winMgr:destroyWindow(P.wrapper)
     
    144171   
    145172    --Destroy details windows.
     173    if destroyDetails == false then
     174        return
     175    end
    146176    for k,v in pairs(P.detailsWindows) do
    147177        if v ~= nil then
     
    151181end
    152182
    153 function P.windowToCarrierHelper(e)
     183function P.windowToPickupHelper(e)
    154184    local we = CEGUI.toWindowEventArgs(e)
    155185    local name = we.window:getName()
    156186
    157187    local match = string.gmatch(name, "%d+")
    158     local carrierNr = tonumber(match())
    159     local pickupNr = tonumber(match())
    160 
    161     local arguments = {}
    162     arguments[1] = carrierNr
    163     arguments[2] = pickupNr
    164     return arguments
    165 end
    166 
    167 function P.createDetailsWindow(pickupIndex, carrierIndex)
    168     local carrier = P.carrierList[carrierIndex]
    169     local pickup = orxonox.PickupManager:getInstance():getPickupRepresentation(pickupIndex, carrier)
    170    
    171     local headerOffset = 35
    172     --Design parameters
    173     local titleHeight = 30
    174     local imageSize = 100
    175     local buttonWidth = 85
    176    
    177     local name = "orxonox/PickupInventory/Carrier" .. carrierIndex .. "/Pickup" .. pickupIndex .. "/Details" .. P.getNewDetailNumber()
     188    local pickupIndex = tonumber(match())
     189
     190    return pickupIndex
     191end
     192
     193function P.createDetailsWindow(pickupIndex)
     194    local pickup = P.pickupsList[pickupIndex]
     195    local representation = orxonox.PickupManager:getInstance():getPickupRepresentation(pickup)
     196
     197    local index = P.getNewDetailNumber()
     198    local name = "orxonox/PickupInventory/Details" .. index
    178199   
    179200    local window = winMgr:createWindow("MenuWidgets/FrameWindow", name)
     
    190211   
    191212    local title = winMgr:createWindow("MenuWidgets/StaticText", name .. "/Title")
    192     title:setText(pickup:getPickupName())
    193     title:setHeight(CEGUI.UDim(0, titleHeight))
     213    title:setText(representation:getPickupName())
     214    title:setHeight(CEGUI.UDim(0, P.textHeight))
    194215    title:setProperty("FrameEnabled", "set:False")
    195216    title:setProperty("BackgroundEnabled", "set:False")
     
    197218   
    198219    local image = winMgr:createWindow("MenuWidgets/StaticImage", name .. "/Image")
    199     image:setProperty("Image", "set:PickupInventory image:" .. pickup:getInventoryRepresentation())
     220    image:setProperty("Image", "set:PickupInventory image:" .. representation:getInventoryRepresentation())
    200221    image:setProperty("BackgroundEnabled", "set:False")
    201222    image:setProperty("FrameEnabled", "set:True")
    202     image:setSize(CEGUI.UVector2(CEGUI.UDim(0, imageSize), CEGUI.UDim(0, imageSize)))
    203     image:setYPosition(CEGUI.UDim(0, titleHeight + 5))
     223    image:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.detailImageSize), CEGUI.UDim(0, P.detailImageSize)))
     224    image:setYPosition(CEGUI.UDim(0, P.textHeight + 5))
    204225    wrapper:addChildWindow(image)
    205226   
    206227    local box = winMgr:createWindow("MenuWidgets/ScrollablePane", name .. "/Description")
    207     box:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -1*(imageSize + 10)),CEGUI.UDim(1, -(titleHeight + 5 + titleHeight + 20))))
    208     box:setPosition(CEGUI.UVector2(CEGUI.UDim(0, imageSize + 10),CEGUI.UDim(0, titleHeight + 5)))
    209     local description = winMgr:createWindow("TaharezLook/StaticText", name .. "/Description/Text")
    210     description:setText(pickup:getPickupDescription())
     228    box:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -1*(P.detailImageSize + 10)),CEGUI.UDim(1, -(P.textHeight + 5 + P.textHeight + 20))))
     229    box:setPosition(CEGUI.UVector2(CEGUI.UDim(0, P.detailImageSize + 10),CEGUI.UDim(0, P.textHeight + 5)))
     230    local description = winMgr:createWindow("MenuWidgets/StaticText", name .. "/Description/Text")
     231    description:setText(representation:getPickupDescription())
    211232    description:setProperty("HorzFormatting", "WordWrapLeftAligned")
    212233    description:setProperty("VertFormatting", "TopAligned")
    213234    box:addChildWindow(description)
    214235    wrapper:addChildWindow(box)
    215    
     236
    216237    local useButton = winMgr:createWindow("MenuWidgets/Button", name .. "/UseButton")
    217     useButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0, imageSize+10),CEGUI.UDim(1, -40)))
    218     useButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, buttonWidth), CEGUI.UDim(0, titleHeight)))
    219     useButton:setText("use")
    220     orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.name .. ".InventoryUseButton_clicked")
     238    useButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0, P.detailImageSize+10),CEGUI.UDim(1, -40)))
     239    useButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.buttonWidth), CEGUI.UDim(0, P.textHeight)))
     240    if pickup:isUsed() == false then
     241        useButton:setText("use")
     242        orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.name .. ".InventoryUseDetailButton_clicked")
     243        if pickup:isUsable() == false then
     244            useButton:setEnabled(false)
     245        end
     246    else
     247        useButton:setText("unuse")
     248        orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.name .. ".InventoryUnuseDetailButton_clicked")
     249        if pickup:isUnusable() == false then
     250            useButton:setEnabled(false)
     251        end
     252    end
    221253    wrapper:addChildWindow(useButton)
    222254   
    223255    local dropButton = winMgr:createWindow("MenuWidgets/Button", name .. "/DropButton")
    224     dropButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0, imageSize+10+buttonWidth+10),CEGUI.UDim(1, -40)))
    225     dropButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, buttonWidth), CEGUI.UDim(0, titleHeight)))
     256    dropButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0, P.detailImageSize+10+P.buttonWidth+10),CEGUI.UDim(1, -40)))
     257    dropButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.buttonWidth), CEGUI.UDim(0, P.textHeight)))
    226258    dropButton:setText("drop")
    227     orxonox.GUIManager:subscribeEventHelper(dropButton, "Clicked", P.name .. ".InventoryDropButton_clicked")
     259    orxonox.GUIManager:subscribeEventHelper(dropButton, "Clicked", P.name .. ".InventoryDropDetailButton_clicked")
    228260    wrapper:addChildWindow(dropButton)
    229    
    230     table.insert(P.detailsWindows, window)
     261
     262    P.detailsWindows[index] = window
     263    P.detailPickups[index] = pickup
    231264   
    232265end
     
    239272        end
    240273    end
    241     return number
     274    return number+1
    242275end
    243276
    244277function P.InventoryUseButton_clicked(e)
    245     local arguments = P.windowToCarrierHelper(e)
    246     orxonox.PickupManager:getInstance():usePickup(arguments[2], P.carrierList[arguments[1]], true)
     278    local pickupIndex = P.windowToPickupHelper(e)
     279    orxonox.PickupManager:getInstance():usePickup(P.pickupsList[pickupIndex], true)
     280end
     281
     282function P.InventoryUnuseButton_clicked(e)
     283    local pickupIndex = P.windowToPickupHelper(e)
     284    orxonox.PickupManager:getInstance():usePickup(P.pickupsList[pickupIndex], false)
    247285end
    248286
    249287function P.InventoryDropButton_clicked(e)
    250     local arguments = P.windowToCarrierHelper(e)
    251     orxonox.PickupManager:getInstance():dropPickup(arguments[2], P.carrierList[arguments[1]])
     288    local pickupIndex = P.windowToPickupHelper(e)
     289    orxonox.PickupManager:getInstance():dropPickup(P.pickupsList[pickupIndex])
    252290end
    253291
    254292function P.InventoryDetailsButton_clicked(e)
    255     local arguments = P.windowToCarrierHelper(e)
    256     P.createDetailsWindow(arguments[2], arguments[1])
     293    local pickupIndex = P.windowToPickupHelper(e)
     294    P.createDetailsWindow(pickupIndex)
     295end
     296
     297function P.InventoryUseDetailButton_clicked(e)
     298    local pickupIndex = P.windowToPickupHelper(e)
     299    orxonox.PickupManager:getInstance():usePickup(P.detailPickups[pickupIndex], true)
     300end
     301
     302function P.InventoryUnuseDetailButton_clicked(e)
     303    local pickupIndex = P.windowToPickupHelper(e)
     304    orxonox.PickupManager:getInstance():usePickup(P.detailPickups[pickupIndex], false)
     305end
     306
     307function P.InventoryDropDetailButton_clicked(e)
     308    local pickupIndex = P.windowToPickupHelper(e)
     309    orxonox.PickupManager:getInstance():dropPickup(P.detailPickups[pickupIndex])
    257310end
    258311
     
    262315    local name = we.window:getName()
    263316    local match = string.gmatch(name, "%d+")
    264     local carrierNr = tonumber(match())
    265     local pickupNr = tonumber(match())
    266317    local detailNr = tonumber(match())
    267318   
    268     local window = P.detailsWindows[detailNr+1]
     319    local window = P.detailsWindows[detailNr]
    269320    winMgr:destroyWindow(window)
    270     P.detailsWindows[detailNr+1] = nil
     321    P.detailsWindows[detailNr] = nil
     322    P.detailPickups[detailNr] = nil
    271323end
    272324
  • code/trunk/data/gui/scripts/QuestGUI.lua

    r6746 r7163  
    33local P = createMenuSheet("QuestGUI")
    44
    5 function P.show()
    6     P.window:show() -- TODO: Do this through parent...
    7     P.visible = true
    8 
     5P.rootWindow = nil
     6P.detailsWindows = {}
     7P.quests = {}
     8P.hints = {}
     9P.player = nil
     10
     11-- design parameters
     12P.indentWidth = 20
     13P.scrollbarWidth = 13
     14P.buttonHeight = 30
     15P.titleHeight = 26
     16P.borderWidth = 5
     17
     18function P.onShow()
     19
     20    local questsList = winMgr:getWindow("orxonox/QuestGUI/QuestsList")
     21
     22    P.player = orxonox.GUIManager:getInstance():getPlayer(P.name)
     23    P.rootWindow = P.createQuestGUI();
     24
     25    questsList:addChildWindow(P.rootWindow)
     26end
     27
     28function P.onHide()
     29    P.cleanup()
     30end
     31
     32function P.createQuestGUI()
    933    local questManager = orxonox.QuestManager:getInstance()
    1034
    11     local questsList = winMgr:getWindow("orxonox/QuestGUI/QuestsList")
    12 
    13     local window = questManager:getQuestGUI(P.name)
    14 
    15     questsList:addChildWindow(window)
    16 
     35    local depth = 0
     36    local index = 0
     37
     38    local questWindow = winMgr:createWindow("MenuWidgets/ScrollablePane", "orxonox/QuestGUI/Quests")
     39    questWindow:setSize(CEGUI.UVector2(CEGUI.UDim(1, 0),CEGUI.UDim(1, 0)))
     40
     41    -- Iterate through all parent-quests.
     42    local numParentQuests = orxonox.QuestManager:getInstance():getNumParentQuests(P.player)
     43    local i = 0
     44    while i <= numParentQuests-1 do
     45        local quest = orxonox.QuestManager:getInstance():getParentQuest(P.player, i)
     46        index = P.createQuestNodes(questWindow, quest, depth, index)
     47        i = i+1
     48    end
     49
     50    return questWindow
     51end
     52
     53function P.createQuestNodes(root, parent, depth, index)
     54    local number = table.getn(P.quests)+1
     55    local name = "orxonox/QuestGUI/Quests/" .. number
     56    local node = winMgr:createWindow("MenuWidgets/TabButton", name)
     57    node:setText(orxonox.QuestManager:getInstance():getDescription(parent):getTitle())
     58    node:setPosition(CEGUI.UVector2(CEGUI.UDim(0, P.indentWidth*depth), CEGUI.UDim(0, P.buttonHeight*index)))
     59    node:setSize(CEGUI.UVector2(CEGUI.UDim(1, -P.indentWidth*depth-P.scrollbarWidth), CEGUI.UDim(0, P.buttonHeight)))
     60    orxonox.GUIManager:subscribeEventHelper(node, "Clicked", P.name .. ".openDetails_clicked")
     61    root:addChildWindow(node)
     62   
     63    table.insert(P.quests, parent)
     64
     65    index = index+1
     66
     67    -- Iterate through all sub-quests.
     68    local numQuests = orxonox.QuestManager:getInstance():getNumSubQuests(parent, P.player)
     69    local i = 0
     70    while i <= numQuests-1 do
     71        local quest = orxonox.QuestManager:getInstance():getSubQuest(parent, P.player, i)
     72        index = P.createQuestNodes(root, quest, depth+1, index)
     73        i = i+1
     74    end
     75
     76    return index;
     77end
     78
     79function P.cleanup()
     80    winMgr:destroyWindow(P.rootWindow)
     81    for k,v in pairs(P.detailsWindows) do
     82        if v ~= nil then
     83            winMgr:destroyWindow(v)
     84            P.detailsWindows[k] = nil
     85        end
     86    end
     87    P.detailsWindows = {}
     88
     89    P.quests = {}
     90    P.hints = {}
     91    P.player = nil
     92
     93    winMgr:destroyWindow(P.rootWindow)
     94    P.rootWindow = nil
     95end
     96
     97function P.openDetails_clicked(e)
     98    --Get some numbers from the window
     99    local we = CEGUI.toWindowEventArgs(e)
     100    local name = we.window:getName()
     101    local match = string.gmatch(name, "%d+")
     102    local questNr = tonumber(match())
     103
     104    name = name .. "/Details" .. P.getNewDetailNumber()
     105    quest = P.quests[questNr]
     106
     107    local details = winMgr:createWindow("MenuWidgets/FrameWindow", name)
     108    details:setSize(CEGUI.UVector2(CEGUI.UDim(0.7, 0), CEGUI.UDim(0.7, 0)))
     109    details:setPosition(CEGUI.UVector2(CEGUI.UDim(0.1, 0), CEGUI.UDim(0.1, 0)))
     110    details:setText(orxonox.QuestManager:getInstance():getDescription(quest):getTitle())
     111    details:setProperty("Alpha", 1.0)
     112    details:setProperty("InheritsAlpha", "setFalse")
     113    orxonox.GUIManager:subscribeEventHelper(details, "CloseClicked", P.name .. ".closeDetails_clicked")
     114
     115    table.insert(P.detailsWindows, details)
     116
     117    name = name .. "/Scrollable"
     118    local window = winMgr:createWindow("MenuWidgets/ScrollablePane", name)
     119    window:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -2*P.borderWidth),CEGUI.UDim(1.0, -P.titleHeight)))
     120    window:setPosition(CEGUI.UVector2(CEGUI.UDim(0, P.borderWidth), CEGUI.UDim(0, P.titleHeight)))
     121    details:addChildWindow(window)
     122
     123    local offset = 0
     124
     125    local status = winMgr:createWindow("MenuWidgets/StaticText", name .. "/Status")
     126    window:addChildWindow(status)
     127    status:setProperty("HorzFormatting", "WordWrapLeftAligned")
     128    status:setProperty("VertFormatting", "TopAligned")
     129    if quest:isActive(P.player) then
     130        status:setText("This quest is active.")
     131    elseif quest:isCompleted(P.player) then
     132        status:setText("This quest was completed.")
     133    elseif quest:isFailed(P.player) then
     134        status:setText("This quest was failed.")
     135    end
     136    status:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, offset)))
     137    status:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -P.scrollbarWidth), CEGUI.UDim(1.0, 0)))
     138    local height = getStaticTextWindowHeight(status)
     139    status:setHeight(CEGUI.UDim(0, height))
     140    offset = offset + height
     141
     142    local descriptionTitle = winMgr:createWindow("MenuWidgets/StaticText", name .. "/Description/Title");
     143    window:addChildWindow(descriptionTitle)
     144    descriptionTitle:setProperty("HorzFormatting", "HorzCentred")
     145    descriptionTitle:setProperty("VertFormatting", "TopAligned")
     146    descriptionTitle:setText("Description:")
     147    descriptionTitle:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, offset)))
     148    descriptionTitle:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -P.scrollbarWidth), CEGUI.UDim(1.0, 0)))
     149    height = getStaticTextWindowHeight(descriptionTitle)
     150    descriptionTitle:setHeight(CEGUI.UDim(0, height))
     151    offset = offset + height
     152
     153    local description = winMgr:createWindow("MenuWidgets/StaticText", name .. "/Description");
     154    window:addChildWindow(description)
     155    description:setProperty("HorzFormatting", "WordWrapLeftAligned")
     156    description:setProperty("VertFormatting", "TopAligned")
     157    description:setText(orxonox.QuestManager:getInstance():getDescription(quest):getDescription())
     158    description:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, offset)))
     159    description:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -P.scrollbarWidth), CEGUI.UDim(1.0, 0)))
     160    height = getStaticTextWindowHeight(description)
     161    description:setHeight(CEGUI.UDim(0, height))
     162    offset = offset + height
     163
     164    -- Display the hints of this quest
     165    local numHints = orxonox.QuestManager:getInstance():getNumHints(quest, P.player)
     166    if numHints > 0 then
     167        local hintsTitle = winMgr:createWindow("MenuWidgets/StaticText", name .. "/Hints/Title");
     168        window:addChildWindow(hintsTitle)
     169        hintsTitle:setProperty("HorzFormatting", "HorzCentred")
     170        hintsTitle:setProperty("VertFormatting", "TopAligned")
     171        hintsTitle:setText("Hints:")
     172        hintsTitle:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, offset)))
     173        hintsTitle:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -P.scrollbarWidth), CEGUI.UDim(1.0, 0)))
     174        height = getStaticTextWindowHeight(hintsTitle)
     175        hintsTitle:setHeight(CEGUI.UDim(0, height))
     176        offset = offset + height
     177    end
     178    local i = 0
     179    while i <= numHints-1 do
     180        local hint = orxonox.QuestManager:getInstance():getHints(quest, P.player, i)
     181        table.insert(P.hints, hint)
     182        local number = table.getn(P.hints)
     183        local node = winMgr:createWindow("MenuWidgets/TabButton", name .. "/Hints" .. number)
     184        node:setText(orxonox.QuestManager:getInstance():getDescription(hint):getTitle())
     185        node:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, offset)))
     186        node:setSize(CEGUI.UVector2(CEGUI.UDim(1, -P.scrollbarWidth), CEGUI.UDim(0, P.buttonHeight)))
     187        window:addChildWindow(node)
     188        offset = offset + P.buttonHeight
     189
     190        orxonox.GUIManager:subscribeEventHelper(node, "Clicked", P.name .. ".openHintDetails_clicked")
     191        i = i+1
     192    end
     193
     194    local window = winMgr:getWindow("orxonox/QuestGUI/Background")
     195    window:addChildWindow(details)
     196end
     197
     198function P.getNewDetailNumber()
     199    local number = table.getn(P.detailsWindows)
     200    for k,v in pairs(P.detailsWindows) do
     201        if v == nil then
     202            number = k-1
     203        end
     204    end
     205    return number+1
     206end
     207
     208function P.closeDetails_clicked(e)
     209    local we = CEGUI.toWindowEventArgs(e)
     210    local name = we.window:getName()
     211    local match = string.gmatch(name, "%d+")
     212    match()
     213    local detailsNr = tonumber(match())
     214
     215    winMgr:destroyWindow(P.detailsWindows[detailsNr])
     216    P.detailsWindows[detailsNr] = nil
     217end
     218
     219function P.openHintDetails_clicked(e)
     220    --Get some numbers from the window
     221    local we = CEGUI.toWindowEventArgs(e)
     222    local name = we.window:getName()
     223    local match = string.gmatch(name, "%d+")
     224    match()
     225    match()
     226    local hintNr = tonumber(match())
     227
     228    name = name .. "/Details" .. P.getNewDetailNumber()
     229    hint = P.hints[hintNr]
     230
     231    local details = winMgr:createWindow("MenuWidgets/FrameWindow", name)
     232    details:setSize(CEGUI.UVector2(CEGUI.UDim(0.7, 0), CEGUI.UDim(0.7, 0)))
     233    details:setPosition(CEGUI.UVector2(CEGUI.UDim(0.1, 0), CEGUI.UDim(0.1, 0)))
     234    details:setText(orxonox.QuestManager:getInstance():getDescription(hint):getTitle())
     235    details:setProperty("Alpha", 1.0)
     236    details:setProperty("InheritsAlpha", "setFalse")
     237    orxonox.GUIManager:subscribeEventHelper(details, "CloseClicked", P.name .. ".closeHintDetails_clicked")
     238
     239    table.insert(P.detailsWindows, details)
     240
     241    name = name .. "/Scrollable"
     242    local window = winMgr:createWindow("MenuWidgets/ScrollablePane", name)
     243    window:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -2*P.borderWidth),CEGUI.UDim(1.0, -P.titleHeight)))
     244    window:setPosition(CEGUI.UVector2(CEGUI.UDim(0, P.borderWidth), CEGUI.UDim(0, P.titleHeight)))
     245    details:addChildWindow(window)
     246
     247    local offset = 0
     248   
     249    local descriptionTitle = winMgr:createWindow("MenuWidgets/StaticText", name .. "/Description/Title");
     250    window:addChildWindow(descriptionTitle)
     251    descriptionTitle:setProperty("HorzFormatting", "HorzCentred")
     252    descriptionTitle:setProperty("VertFormatting", "TopAligned")
     253    descriptionTitle:setText("Description:")
     254    descriptionTitle:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, offset)))
     255    descriptionTitle:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -P.scrollbarWidth), CEGUI.UDim(1.0, 0)))
     256    height = getStaticTextWindowHeight(descriptionTitle)
     257    descriptionTitle:setHeight(CEGUI.UDim(0, height))
     258    offset = offset + height
     259
     260    local description = winMgr:createWindow("MenuWidgets/StaticText", name .. "/Description");
     261    window:addChildWindow(description)
     262    description:setProperty("HorzFormatting", "WordWrapLeftAligned")
     263    description:setProperty("VertFormatting", "TopAligned")
     264    description:setText(orxonox.QuestManager:getInstance():getDescription(hint):getDescription())
     265    description:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, offset)))
     266    description:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -P.scrollbarWidth), CEGUI.UDim(1.0, 0)))
     267    height = getStaticTextWindowHeight(description)
     268    description:setHeight(CEGUI.UDim(0, height))
     269
     270    local window = winMgr:getWindow("orxonox/QuestGUI/Background")
     271    window:addChildWindow(details)
     272end
     273
     274function P.closeHintDetails_clicked(e)
     275    local we = CEGUI.toWindowEventArgs(e)
     276    local name = we.window:getName()
     277    local match = string.gmatch(name, "%d+")
     278    match()
     279    match()
     280    match()
     281    local detailsNr = tonumber(match())
     282
     283    winMgr:destroyWindow(P.detailsWindows[detailsNr])
     284    P.detailsWindows[detailsNr] = nil
    17285end
    18286
  • code/trunk/data/gui/scripts/SettingsMenu.lua

    r6748 r7163  
    2424end
    2525
    26 function P.SettingsResetSettingsButton_clicked(e)
    27     -- reset settings
    28     logMessage(0, "event: reset settings")
     26function P.SettingsMiscellaneousButton_clicked(e)
     27    showMenuSheet("MiscConfigMenu", true)
    2928end
    3029
  • code/trunk/data/gui/scripts/SingleplayerMenu.lua

    r6754 r7163  
    2727        end
    2828    end
     29
    2930end
    3031
Note: See TracChangeset for help on using the changeset viewer.