Changeset 11406 for code/branches
- Timestamp:
- Apr 27, 2017, 3:36:57 PM (8 years ago)
- 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 35 35 -- Dialogue.lua 36 36 37 local P = createMenuSheet(" PickupInventory")37 local P = createMenuSheet("Dialogue") 38 38 39 39 P.wrapper = nil … … 75 75 76 76 -- 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 112 78 113 79 -- Update main inventory. … … 119 85 120 86 function P.createInventory() 121 local pickupManager = orxonox. PickupManager:getInstance()87 local pickupManager = orxonox.DialogueManager:getInstance() 122 88 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") 125 93 P.wrapper:setSize(CEGUI.UVector2(CEGUI.UDim(1,0),CEGUI.UDim(1,0))) 126 94 root:addChildWindow(P.wrapper) 127 95 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 142 97 143 98 end 144 99 145 function P.createPickupEntry(index, pickup)146 local representation = orxonox.PickupManager:getInstance():getRepresentation(pickup.representationName)147 100 148 local name = "orxonox/PickupInventory/Box/Pickup" .. index149 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 then172 useButton:setText("use")173 orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.name .. ".InventoryUseButton_clicked")174 if pickup.usable == false then175 useButton:setEnabled(false)176 end177 else178 useButton:setText("unuse")179 orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.name .. ".InventoryUnuseButton_clicked")180 if pickup.unusable == false then181 useButton:setEnabled(false)182 end183 end184 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 item201 end202 101 203 102 function P.cleanup(destroyDetails) … … 217 116 end 218 117 219 function P.windowToPickupHelper(e)220 local we = CEGUI.toWindowEventArgs(e)221 local name = we.window:getName()222 118 223 local match = string.gmatch(name, "%d+")224 local pickupIndex = tonumber(match())225 226 return pickupIndex227 end228 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" .. index235 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 then277 useButton:setText("use")278 orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.name .. ".InventoryUseDetailButton_clicked")279 if pickup.usable == false then280 useButton:setEnabled(false)281 end282 else283 useButton:setText("unuse")284 orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.name .. ".InventoryUnuseDetailButton_clicked")285 if pickup.unusable == false then286 useButton:setEnabled(false)287 end288 end289 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] = window299 P.detailPickups[index] = pickup300 301 end302 303 function P.getNewDetailNumber()304 local number = table.getn(P.detailsWindows)305 for k,v in pairs(P.detailsWindows) do306 if v == nil then307 number = k-1308 end309 end310 return number+1311 end312 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 end318 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 end324 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 end330 331 function P.InventoryDetailsButton_clicked(e)332 local pickupIndex = P.windowToPickupHelper(e)333 P.createDetailsWindow(pickupIndex)334 end335 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 end341 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 end347 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 end353 354 function P.closeDetailWindow(e)355 --Get some numbers from the window356 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 end363 364 function P.destroyDetailWindow(detailNr)365 local window = P.detailsWindows[detailNr]366 winMgr:destroyWindow(window)367 P.detailsWindows[detailNr] = nil368 P.detailPickups[detailNr] = nil369 end370 119 371 120 function P.InventoryBackButton_clicked(e) 372 orxonox.CommandExecutor:execute("OrxonoxOverlay toggleVisibility PickupInventory")121 orxonox.CommandExecutor:execute("OrxonoxOverlay toggleVisibility Dialogue") 373 122 end 374 123 -
code/branches/Dialogue_FS17/src/modules/dialogue/CMakeLists.txt
r11401 r11406 8 8 MODULE 9 9 FIND_HEADER_FILES 10 TOLUA_FILES 11 DialogueManager.h 10 12 LINK_LIBRARIES 11 13 orxonox -
code/branches/Dialogue_FS17/src/modules/dialogue/DialogueManager.cc
r11401 r11406 22 22 23 23 DialogueManager::DialogueManager(Context* context): BaseObject(context){ 24 orxout() << "Dialog Konstruktor" << endl; 24 25 RegisterObject(DialogueManager); 25 26 … … 34 35 35 36 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; 38 41 } 39 42 40 43 std::string DialogueManager::getquestion(void){ 44 orxout() << question << endl; 41 45 return question; 42 46 } -
code/branches/Dialogue_FS17/src/modules/dialogue/DialogueManager.h
r11401 r11406 14 14 #include "core/EventIncludes.h" 15 15 16 //tolua_begin 17 namespace orxonox 18 //tolua_end 19 {//toluaexport 20 class _OrxonoxExport DialogueManager : public Singleton<DialogueManager>, public BaseObject 21 { 16 17 namespace orxonox //tolua_export 18 19 {//tolua_export 20 class _OrxonoxExport DialogueManager //tolua_export 21 : public Singleton<DialogueManager>, public BaseObject 22 {//tolua_export 22 23 friend class Singleton<DialogueManager>; 23 //tolua_begin24 24 25 public: 25 26 26 27 27 DialogueManager(Context* context); // tolua_export28 DialogueManager(Context* context); 28 29 29 30 30 static DialogueManager& getInstance() { return Singleton<DialogueManager>::getInstance(); } 31 static DialogueManager& getInstance() { return Singleton<DialogueManager>::getInstance(); } //tolua_export 31 32 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 34 35 35 36 … … 48 49 std::string npc; 49 50 std::vector<std::string> options; 50 //tolua_end51 51 52 */ 52 53 private: … … 54 55 static DialogueManager* singletonPtr_s; 55 56 56 };//toluaexport 57 } 57 };//tolua_export 58 }//tolua_export 59 -
code/branches/Dialogue_FS17/src/modules/dialogue/NextQuestion.cc
r11401 r11406 3 3 #include "core/CoreIncludes.h" 4 4 #include "core/GUIManager.h" 5 #include "overlays/OrxonoxOverlay.h" 5 6 6 7 … … 16 17 RegisterObject(NextQuestion); 17 18 orxout() << "Klasse aufgerufen" << endl; 19 DialogueManager* d = new DialogueManager(context); 20 18 21 19 22 } 20 23 21 24 void NextQuestion::setquestion(std::string question){ 22 question=question;25 this->question=question; 23 26 } 24 27 25 28 std::string NextQuestion::getquestion(void){ 29 orxout() << question; 26 30 return question; 27 31 } … … 47 51 orxout() << "bTriggered is " << bTriggered << endl; 48 52 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 53 64 return false; 54 65 }
Note: See TracChangeset
for help on using the changeset viewer.