Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 27, 2017, 3:36:57 PM (8 years ago)
Author:
rrogge
Message:

Dialogfenster geht auf :D

Location:
code/branches/Dialogue_FS17
Files:
2 added
2 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/Dialogue_FS17/data/gui/scripts/Dialogue.lua

    r11401 r11406  
    3535-- Dialogue.lua
    3636
    37 local P = createMenuSheet("PickupInventory")
     37local P = createMenuSheet("Dialogue")
    3838
    3939P.wrapper = nil
     
    7575
    7676    -- Update opened detail windows.
    77     for k,v in pairs(P.detailsWindows) do
    78         if v ~= nil then
    79             local pickup = P.detailPickups[k]
    80             if pickup ~= nil and pickup ~= 0 then
    81                 local useButton = winMgr:getWindow("orxonox/PickupInventory/Details" .. k .. "/UseButton")
    82                 local dropButton = winMgr:getWindow("orxonox/PickupInventory/Details" .. k .. "/DropButton")
    83                 if orxonox.PickupManager:getInstance():isValidPickup(pickup.pickup) == false then
    84                     useButton:setEnabled(false)
    85                     dropButton:setEnabled(false)
    86                     P.detailPickups[k] = nil
    87                 else
    88                     useButton:setEnabled(true)
    89                     if pickup.inUse == true then
    90                         useButton:setText("unuse")
    91                         orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.name .. ".InventoryUseDetailButton_clicked")
    92                         if pickup.usable == false then
    93                             useButton:setEnabled(false)
    94                         end
    95                     else
    96                         useButton:setText("use")
    97                         orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.name .. ".InventoryUnuseDetailButton_clicked")
    98                         if pickup.unusable == false then
    99                             useButton:setEnabled(false)
    100                         end
    101                     end
    102 
    103                     if pickup.pickedUp == false then
    104                         useButton:setEnabled(false)
    105                         dropButton:setEnabled(false)
    106                         P.detailPickups[k] = nil
    107                     end
    108                 end
    109             end
    110         end
    111     end
     77   
    11278
    11379    -- Update main inventory.
     
    11985
    12086function P.createInventory()
    121     local pickupManager = orxonox.PickupManager:getInstance()
     87    local pickupManager = orxonox.DialogueManager:getInstance()
    12288   
    123     local root = winMgr:getWindow("orxonox/PickupInventory/Inventory")
    124     P.wrapper = winMgr:createWindow("MenuWidgets/ScrollablePane", "orxonox/PickupInventory/Inventory/Wrapper")
     89    local root = winMgr:getWindow("orxonox/Dialogue/Inventory")
     90    local question = orxonox.DialogueManager:getInstance():getquestion()
     91    root:setText(question)
     92    P.wrapper = winMgr:createWindow("MenuWidgets/ScrollablePane", "orxonox/Dialogue/Inventory/Wrapper")
    12593    P.wrapper:setSize(CEGUI.UVector2(CEGUI.UDim(1,0),CEGUI.UDim(1,0)))
    12694    root:addChildWindow(P.wrapper)
    12795   
    128     P.pickupsList = {}
    129 
    130     local numPickups = pickupManager:getNumPickups()
    131     local counter = 1
    132     local offset = 0
    133     while counter <= numPickups do
    134         local pickup = pickupManager:popPickup()
    135         table.insert(P.pickupsList, pickup)
    136         local window = P.createPickupEntry(counter, pickup)
    137         window:setYPosition(CEGUI.UDim(0,offset))
    138         offset = offset + window:getHeight():asAbsolute(1)
    139         P.wrapper:addChildWindow(window)
    140         counter = counter + 1
    141     end
     96   
    14297
    14398end
    14499
    145 function P.createPickupEntry(index, pickup)
    146     local representation = orxonox.PickupManager:getInstance():getRepresentation(pickup.representationName)
    147100
    148     local name = "orxonox/PickupInventory/Box/Pickup" .. index
    149 
    150     local item = winMgr:createWindow("MenuWidgets/StaticText", name)
    151     item:setSize(CEGUI.UVector2(CEGUI.UDim(1, 0), CEGUI.UDim(0, P.imageHeight)))
    152     item:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, 0)))
    153 
    154     local image = winMgr:createWindow("MenuWidgets/StaticImage", name .. "/Image")
    155     image:setProperty("Image", "set:PickupInventory image:" .. representation:getInventoryRepresentation())
    156     image:setProperty("BackgroundEnabled", "set:False")
    157     image:setProperty("FrameEnabled", "set:True")
    158     image:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.imageHeight), CEGUI.UDim(0, P.imageHeight)))
    159     item:addChildWindow(image)
    160 
    161     local title = winMgr:createWindow("MenuWidgets/StaticText", name .. "/Title")
    162     title:setPosition(CEGUI.UVector2(CEGUI.UDim(0, P.imageHeight+5), CEGUI.UDim(0, (P.imageHeight-P.textHeight)/2)))
    163     title:setSize(CEGUI.UVector2(CEGUI.UDim(0.3, 0), CEGUI.UDim(0, P.textHeight)))
    164     title:setText(representation:getPickupName())
    165     title:setProperty("FrameEnabled", "set:False")
    166     item:addChildWindow(title)
    167 
    168     local useButton = winMgr:createWindow("MenuWidgets/Button", name .. "/UseButton")
    169     useButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0.3, P.imageHeight+10),CEGUI.UDim(0, (P.imageHeight-P.textHeight)/2)))
    170     useButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.buttonWidth), CEGUI.UDim(0, P.textHeight)))
    171     if pickup.inUse == false then
    172         useButton:setText("use")
    173         orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.name .. ".InventoryUseButton_clicked")
    174         if pickup.usable == false then
    175             useButton:setEnabled(false)
    176         end
    177     else
    178         useButton:setText("unuse")
    179         orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.name .. ".InventoryUnuseButton_clicked")
    180         if pickup.unusable == false then
    181             useButton:setEnabled(false)
    182         end
    183     end
    184     item:addChildWindow(useButton)
    185 
    186     local dropButton = winMgr:createWindow("MenuWidgets/Button", name .. "/DropButton")
    187     dropButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0.3, P.imageHeight+15+P.buttonWidth),CEGUI.UDim(0, (P.imageHeight-P.textHeight)/2)))
    188     dropButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.buttonWidth), CEGUI.UDim(0, P.textHeight)))
    189     dropButton:setText("drop")
    190     orxonox.GUIManager:subscribeEventHelper(dropButton, "Clicked", P.name .. ".InventoryDropButton_clicked")
    191     item:addChildWindow(dropButton)
    192 
    193     local detailsButton = winMgr:createWindow("MenuWidgets/Button", name .. "/DetailsButton")
    194     detailsButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0.3, P.imageHeight+20+2*P.buttonWidth),CEGUI.UDim(0, (P.imageHeight-P.textHeight)/2)))
    195     detailsButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.buttonWidth), CEGUI.UDim(0, P.textHeight)))
    196     detailsButton:setText("details")
    197     orxonox.GUIManager:subscribeEventHelper(detailsButton, "Clicked", P.name .. ".InventoryDetailsButton_clicked")
    198     item:addChildWindow(detailsButton)
    199 
    200     return item
    201 end
    202101
    203102function P.cleanup(destroyDetails)
     
    217116end
    218117
    219 function P.windowToPickupHelper(e)
    220     local we = CEGUI.toWindowEventArgs(e)
    221     local name = we.window:getName()
    222118
    223     local match = string.gmatch(name, "%d+")
    224     local pickupIndex = tonumber(match())
    225 
    226     return pickupIndex
    227 end
    228 
    229 function P.createDetailsWindow(pickupIndex)
    230     local pickup = P.pickupsList[pickupIndex]
    231     local representation = orxonox.PickupManager:getInstance():getRepresentation(pickup.representationName)
    232 
    233     local index = P.getNewDetailNumber()
    234     local name = "orxonox/PickupInventory/Details" .. index
    235    
    236     local window = winMgr:createWindow("MenuWidgets/FrameWindow", name)
    237     window:setSize(CEGUI.UVector2(CEGUI.UDim(0.5,0),CEGUI.UDim(0.4,0)))
    238     orxonox.GUIManager:subscribeEventHelper(window, "CloseClicked", P.name .. ".closeDetailWindow")
    239    
    240     local root = winMgr:getWindow("orxonox/PickupInventory/Background")
    241     root:addChildWindow(window)
    242    
    243     local wrapper = winMgr:createWindow("DefaultWindow", name .. "/Wrapper")
    244     wrapper:setSize(CEGUI.UVector2(CEGUI.UDim(1, -20),CEGUI.UDim(1, -50)))
    245     wrapper:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 10),CEGUI.UDim(0, 40)))
    246     window:addChildWindow(wrapper)
    247    
    248     local title = winMgr:createWindow("MenuWidgets/StaticText", name .. "/Title")
    249     title:setText(representation:getPickupName())
    250     title:setHeight(CEGUI.UDim(0, P.textHeight))
    251     title:setProperty("FrameEnabled", "set:False")
    252     title:setProperty("BackgroundEnabled", "set:False")
    253     wrapper:addChildWindow(title)
    254    
    255     local image = winMgr:createWindow("MenuWidgets/StaticImage", name .. "/Image")
    256     image:setProperty("Image", "set:PickupInventory image:" .. representation:getInventoryRepresentation())
    257     image:setProperty("BackgroundEnabled", "set:False")
    258     image:setProperty("FrameEnabled", "set:True")
    259     image:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.detailImageSize), CEGUI.UDim(0, P.detailImageSize)))
    260     image:setYPosition(CEGUI.UDim(0, P.textHeight + 5))
    261     wrapper:addChildWindow(image)
    262    
    263     local box = winMgr:createWindow("MenuWidgets/ScrollablePane", name .. "/Description")
    264     box:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -1*(P.detailImageSize + 10)),CEGUI.UDim(1, -(P.textHeight + 5 + P.textHeight + 20))))
    265     box:setPosition(CEGUI.UVector2(CEGUI.UDim(0, P.detailImageSize + 10),CEGUI.UDim(0, P.textHeight + 5)))
    266     local description = winMgr:createWindow("MenuWidgets/StaticText", name .. "/Description/Text")
    267     description:setText(representation:getPickupDescription())
    268     description:setProperty("HorzFormatting", "WordWrapLeftAligned")
    269     description:setProperty("VertFormatting", "TopAligned")
    270     box:addChildWindow(description)
    271     wrapper:addChildWindow(box)
    272 
    273     local useButton = winMgr:createWindow("MenuWidgets/Button", name .. "/UseButton")
    274     useButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0, P.detailImageSize+10),CEGUI.UDim(1, -40)))
    275     useButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.buttonWidth), CEGUI.UDim(0, P.textHeight)))
    276     if pickup.inUse == false then
    277         useButton:setText("use")
    278         orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.name .. ".InventoryUseDetailButton_clicked")
    279         if pickup.usable == false then
    280             useButton:setEnabled(false)
    281         end
    282     else
    283         useButton:setText("unuse")
    284         orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.name .. ".InventoryUnuseDetailButton_clicked")
    285         if pickup.unusable == false then
    286             useButton:setEnabled(false)
    287         end
    288     end
    289     wrapper:addChildWindow(useButton)
    290    
    291     local dropButton = winMgr:createWindow("MenuWidgets/Button", name .. "/DropButton")
    292     dropButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0, P.detailImageSize+10+P.buttonWidth+10),CEGUI.UDim(1, -40)))
    293     dropButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.buttonWidth), CEGUI.UDim(0, P.textHeight)))
    294     dropButton:setText("drop")
    295     orxonox.GUIManager:subscribeEventHelper(dropButton, "Clicked", P.name .. ".InventoryDropDetailButton_clicked")
    296     wrapper:addChildWindow(dropButton)
    297 
    298     P.detailsWindows[index] = window
    299     P.detailPickups[index] = pickup
    300    
    301 end
    302 
    303 function P.getNewDetailNumber()
    304     local number = table.getn(P.detailsWindows)
    305     for k,v in pairs(P.detailsWindows) do
    306         if v == nil then
    307             number = k-1
    308         end
    309     end
    310     return number+1
    311 end
    312 
    313 function P.InventoryUseButton_clicked(e)
    314     local pickupIndex = P.windowToPickupHelper(e)
    315     local pickup = P.pickupsList[pickupIndex]
    316     orxonox.PickupManager:getInstance():usePickup(pickup.pickup, true)
    317 end
    318 
    319 function P.InventoryUnuseButton_clicked(e)
    320     local pickupIndex = P.windowToPickupHelper(e)
    321     local pickup = P.pickupsList[pickupIndex]
    322     orxonox.PickupManager:getInstance():usePickup(pickup.pickup, false)
    323 end
    324 
    325 function P.InventoryDropButton_clicked(e)
    326     local pickupIndex = P.windowToPickupHelper(e)
    327     local pickup = P.pickupsList[pickupIndex]
    328     orxonox.PickupManager:getInstance():dropPickup(pickup.pickup)
    329 end
    330 
    331 function P.InventoryDetailsButton_clicked(e)
    332     local pickupIndex = P.windowToPickupHelper(e)
    333     P.createDetailsWindow(pickupIndex)
    334 end
    335 
    336 function P.InventoryUseDetailButton_clicked(e)
    337     local pickupIndex = P.windowToPickupHelper(e)
    338     local pickup = P.detailPickups[pickupIndex]
    339     orxonox.PickupManager:getInstance():usePickup(pickup.pickup, true)
    340 end
    341 
    342 function P.InventoryUnuseDetailButton_clicked(e)
    343     local pickupIndex = P.windowToPickupHelper(e)
    344     local pickup = P.detailPickups[pickupIndex]
    345     orxonox.PickupManager:getInstance():usePickup(pickup.pickup, false)
    346 end
    347 
    348 function P.InventoryDropDetailButton_clicked(e)
    349     local pickupIndex = P.windowToPickupHelper(e)
    350     local pickup = P.detailPickups[pickupIndex]
    351     orxonox.PickupManager:getInstance():dropPickup(pickup.pickup)
    352 end
    353 
    354 function P.closeDetailWindow(e)
    355     --Get some numbers from the window
    356     local we = CEGUI.toWindowEventArgs(e)
    357     local name = we.window:getName()
    358     local match = string.gmatch(name, "%d+")
    359     local detailNr = tonumber(match())
    360    
    361     P.destroyDetailWindow(detailNr)
    362 end
    363 
    364 function P.destroyDetailWindow(detailNr)
    365     local window = P.detailsWindows[detailNr]
    366     winMgr:destroyWindow(window)
    367     P.detailsWindows[detailNr] = nil
    368     P.detailPickups[detailNr] = nil
    369 end
    370119
    371120function P.InventoryBackButton_clicked(e)
    372     orxonox.CommandExecutor:execute("OrxonoxOverlay toggleVisibility PickupInventory")
     121    orxonox.CommandExecutor:execute("OrxonoxOverlay toggleVisibility Dialogue")
    373122end
    374123
  • code/branches/Dialogue_FS17/src/modules/dialogue/CMakeLists.txt

    r11401 r11406  
    88  MODULE
    99  FIND_HEADER_FILES
     10   TOLUA_FILES
     11    DialogueManager.h
    1012  LINK_LIBRARIES
    1113    orxonox
  • code/branches/Dialogue_FS17/src/modules/dialogue/DialogueManager.cc

    r11401 r11406  
    2222
    2323        DialogueManager::DialogueManager(Context* context): BaseObject(context){
     24                orxout() << "Dialog Konstruktor" << endl;
    2425                RegisterObject(DialogueManager);
    2526               
     
    3435   
    3536
    36     void DialogueManager::setquestion(std::string question){
    37                 question=question;
     37    void DialogueManager::setquestion(std::string q){
     38                orxout() << "setquestion" << endl;
     39                question=q;
     40                orxout() << "Question is " << question;
    3841        }
    3942
    4043        std::string DialogueManager::getquestion(void){
     44                orxout() << question << endl;
    4145                return question;
    4246        }
  • code/branches/Dialogue_FS17/src/modules/dialogue/DialogueManager.h

    r11401 r11406  
    1414#include "core/EventIncludes.h"
    1515
    16 //tolua_begin
    17 namespace orxonox
    18 //tolua_end
    19 {//toluaexport
    20         class _OrxonoxExport DialogueManager : public Singleton<DialogueManager>, public BaseObject
    21         {
     16
     17namespace orxonox //tolua_export
     18
     19{//tolua_export
     20        class _OrxonoxExport DialogueManager //tolua_export
     21        : public Singleton<DialogueManager>, public BaseObject
     22        {//tolua_export
    2223                friend class Singleton<DialogueManager>;
    23                 //tolua_begin
     24       
    2425                public:
    2526               
    2627
    27                 DialogueManager(Context* context); // tolua_export
     28                DialogueManager(Context* context);
    2829               
    2930
    30                 static DialogueManager& getInstance() { return Singleton<DialogueManager>::getInstance(); }
     31                static DialogueManager& getInstance() { return Singleton<DialogueManager>::getInstance(); } //tolua_export
    3132               
    32                 void setquestion(std::string question);
    33                 std::string getquestion(void);
     33                void setquestion(std::string question); //tolua_export
     34                std::string getquestion(void); //tolua_export
    3435               
    3536
     
    4849                        std::string npc;
    4950                        std::vector<std::string> options;
    50                 //tolua_end
     51               
    5152*/
    5253private:
     
    5455        static DialogueManager* singletonPtr_s;
    5556
    56         };//toluaexport
    57 }
     57        };//tolua_export
     58}//tolua_export
     59
  • code/branches/Dialogue_FS17/src/modules/dialogue/NextQuestion.cc

    r11401 r11406  
    33#include "core/CoreIncludes.h"
    44#include "core/GUIManager.h"
     5#include "overlays/OrxonoxOverlay.h"
    56
    67
     
    1617        RegisterObject(NextQuestion);
    1718        orxout() << "Klasse aufgerufen" << endl;
     19         DialogueManager* d = new DialogueManager(context);
     20       
    1821
    1922    }
    2023
    2124        void NextQuestion::setquestion(std::string question){
    22                 question=question;
     25                this->question=question;
    2326        }
    2427
    2528        std::string NextQuestion::getquestion(void){
     29                orxout() << question;
    2630                return question;
    2731        }
     
    4751        orxout() << "bTriggered is " << bTriggered << endl;
    4852
    49         for (DialogueManager* hud : ObjectList<DialogueManager>())
    50             m = hud;
    51         m->setquestion(question);
    52         //orxout() << " 1 " << mystring << endl;
     53        //for (DialogueManager* hud : ObjectList<DialogueManager>())
     54            //m = hud;
     55
     56        DialogueManager& m = DialogueManager::getInstance();
     57               
     58        m.setquestion(question);
     59        orxout() << " 1 " << endl;
     60
     61       
     62        OrxonoxOverlay::showOverlay("Dialogue");
     63
    5364        return false;
    5465    }
Note: See TracChangeset for help on using the changeset viewer.