Changeset 11413
- Timestamp:
- May 4, 2017, 4:11:36 PM (8 years ago)
- Location:
- code/branches/Dialogue_FS17
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/Dialogue_FS17/data/gui/scripts/Dialogue.lua
r11407 r11413 93 93 P.wrapper:setSize(CEGUI.UVector2(CEGUI.UDim(1,0),CEGUI.UDim(1,0))) 94 94 root:addChildWindow(P.wrapper) 95 root:addChild(answerButton)96 95 97 96 97 local detailsButton = winMgr:createWindow("MenuWidgets/Button", "/DetailsButton") 98 local a1 = orxonox.DialogueManager:getInstance():getanswers1() 99 detailsButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0.3, P.imageHeight+2*P.buttonWidth),CEGUI.UDim(0, (P.imageHeight-P.textHeight)/2))) 100 detailsButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.buttonWidth), CEGUI.UDim(0, P.textHeight))) 101 detailsButton:setText(a1) 102 orxonox.GUIManager:subscribeEventHelper(detailsButton, "Clicked", P.name ..".a1Button_clicked") 103 root:addChildWindow(detailsButton) 104 105 local a2Button = winMgr:createWindow("MenuWidgets/Button", "/a2Button") 106 local a2 = orxonox.DialogueManager:getInstance():getanswers2() 107 a2Button:setPosition(CEGUI.UVector2(CEGUI.UDim(0.3, P.imageHeight+40+2*P.buttonWidth),CEGUI.UDim(0, (P.imageHeight-P.textHeight)/2))) 108 a2Button:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.buttonWidth), CEGUI.UDim(0, P.textHeight))) 109 a2Button:setText(a2) 110 orxonox.GUIManager:subscribeEventHelper(a2Button, "Clicked", P.name ..".a2Button_clicked") 111 root:addChildWindow(a2Button) 112 98 113 99 114 end … … 119 134 120 135 121 function P.InventoryBackButton_clicked(e) 122 orxonox.CommandExecutor:execute("OrxonoxOverlay toggleVisibility Dialogue") 136 function P.a1Button_clicked(e) 137 orxonox.DialogueManager:getInstance():a1clicked() 138 end 139 140 function P.a2Button_clicked(e) 141 orxonox.DialogueManager:getInstance():a2clicked() 123 142 end 124 143 -
code/branches/Dialogue_FS17/data/levels/events.oxw
r11401 r11413 57 57 --> 58 58 59 <DistanceTrigger name="test" position="0,0,0" target="Pawn" distance=25 stayActive="true"/>59 <DistanceTrigger name="test" position="0,0,0" target="Pawn" distance=25 stayActive="true" /> 60 60 <Backlight position="0,0,0" visible=true frequency=0.6 amplitude=3 material="Flares/lensflare" colour="1,0,1"/> 61 <NextQuestion question="Hello World3"> 61 <NextQuestion question="Continue?" a1="yes" a2="no" > 62 <!-- <possibleQuestions> 63 <NextQuestion question="Are you sure?" a1="yep let me continue" a2="no actually not" /> 64 <NextQuestion question="Why?" a1="Got a dentist's appointment" a2="this sucks" /> 65 </possibleQuestions> --> 62 66 <events> 63 67 <execute> -
code/branches/Dialogue_FS17/src/modules/dialogue/DialogueManager.cc
r11406 r11413 36 36 37 37 void DialogueManager::setquestion(std::string q){ 38 orxout() << "setquestion" << endl;39 38 question=q; 40 orxout() << "Question is " << question;39 41 40 } 42 41 … … 44 43 orxout() << question << endl; 45 44 return question; 45 } 46 void DialogueManager::setanswers1(std::string a1){ 47 orxout() << "setanswers1" << endl; 48 this->a1=a1; 49 orxout() << "A1 is " << a1; 50 } 51 52 void DialogueManager::setanswers2(std::string a2){ 53 this->a2=a2; 54 } 55 56 57 58 std::string DialogueManager::getanswers1(void){ 59 orxout() << "getanswers1" << endl; 60 return a1; 61 } 62 63 std::string DialogueManager::getanswers2(void){ 64 return a2; 65 } 66 bool DialogueManager::a1clicked(void){ 67 orxout() << "a1 clicked" << endl; 68 return true; 69 } 70 bool DialogueManager::a2clicked(void){ 71 orxout() << "a2 clicked" << endl; 72 return true; 46 73 } 47 74 /*void DialogueManager::XMLPort(Element& xmlelement, XMLPort::Mode mode) … … 60 87 61 88 62 void DialogueManager::setanswers(std::string option1, std::string option2, std::string option3){ 63 options.at(0)=option1; 64 options.at(1)=option2; 65 options.at(2)=option3; 66 } 67 89 68 90 vector<std::string> DialogueManager::getanswers(void){ 69 91 return options; -
code/branches/Dialogue_FS17/src/modules/dialogue/DialogueManager.h
r11406 r11413 13 13 #include "core/XMLPort.h" 14 14 #include "core/EventIncludes.h" 15 15 16 16 17 … … 35 36 36 37 37 38 39 38 void setanswers1(std::string a1); //tolua_export 39 void setanswers2(std::string a2); //tolua_export 40 std::string getanswers1(void); //tolua_export 41 std::string getanswers2(void); //tolua_export 42 bool a1clicked(void); //tolua_export 43 bool a2clicked(void); //tolua_export 40 44 /*std::string setnpc(std::string npc); 41 45 … … 52 56 */ 53 57 private: 58 std::string a1; 59 std::string a2; 54 60 std::string question; 55 61 static DialogueManager* singletonPtr_s; -
code/branches/Dialogue_FS17/src/modules/dialogue/NextQuestion.cc
r11406 r11413 1 #include <vector>1 //#include <vector> 2 2 #include <string> 3 3 #include "core/CoreIncludes.h" … … 19 19 DialogueManager* d = new DialogueManager(context); 20 20 21 22 21 } 23 22 … … 32 31 33 32 34 // 33 bool NextQuestion::addposQuestion(NextQuestion* nq){ 34 35 possibleQuestions.push_back(nq); 36 return true; 37 } 35 38 39 const NextQuestion* NextQuestion::getposQuestion(unsigned int i) const 40 { 41 for (NextQuestion* effect : this->possibleQuestions) 42 { 43 if(i == 0) 44 return effect; 45 i--; 46 } 47 return nullptr; } 36 48 37 //XML and Event s hit49 //XML and Event stuff 38 50 void NextQuestion::XMLPort(Element& xmlelement, XMLPort::Mode mode) 39 51 { … … 41 53 42 54 XMLPortParam(NextQuestion, "question", setquestion, getquestion, xmlelement, mode); 55 XMLPortParam(NextQuestion, "a1", setanswers1, getanswers1, xmlelement, mode); 56 XMLPortParam(NextQuestion, "a2", setanswers2, getanswers2, xmlelement, mode); 57 XMLPortObject(NextQuestion, NextQuestion, "possibleQuestions", addposQuestion, getposQuestion, xmlelement, mode); 58 43 59 } 44 60 bool NextQuestion::execute(bool bTriggered, BaseObject* trigger) … … 57 73 58 74 m.setquestion(question); 75 m.setanswers1(a1); 76 m.setanswers2(a2); 59 77 orxout() << " 1 " << endl; 60 78 … … 71 89 XMLPortEventSink(NextQuestion, BaseObject, "execute", execute, xmlelement, mode); 72 90 } 73 /*void NextQuestion::setanswers(std::string option1, std::string option2, std::string option3){ 74 options.at(0)=option1; 75 options.at(1)=option2; 76 options.at(2)=option3; 91 92 93 void NextQuestion::setanswers1(std::string a1){ 94 this->a1=a1; 95 } 96 97 void NextQuestion::setanswers2(std::string a2){ 98 this->a2=a2; 99 } 100 101 102 103 std::string NextQuestion::getanswers1(void){ 104 return a1; 77 105 } 78 106 79 vector<std::string> NextQuestion::getanswers(void){80 return options;107 std::string NextQuestion::getanswers2(void){ 108 return a2; 81 109 } 82 110 83 int NextQuestion::getnumOptions(){ 84 return options.size(); 85 }*/ 111 NextQuestion NextQuestion::compare(){ 112 DialogueManager& m = DialogueManager::getInstance(); 113 if(m.a1clicked()){ 114 return *possibleQuestions[0]; 115 } 116 117 else if(m.a2clicked()){ 118 return *possibleQuestions[1]; 119 } 120 } 121 86 122 87 123 } -
code/branches/Dialogue_FS17/src/modules/dialogue/NextQuestion.h
r11401 r11413 1 #include <vector>1 //#include <vector> 2 2 #include <string> 3 3 #include "core/class/Identifier.h" … … 23 23 24 24 25 25 bool addposQuestion(NextQuestion* nq); 26 const NextQuestion* getposQuestion(unsigned int index) const; 26 27 27 28 28 29 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 29 30 30 /*void setanswers(std::string option1, std::string option2, std::string option3); 31 std::vector <std::string> getanswers(void); 31 void setanswers1(std::string a1); 32 void setanswers2(std::string a2); 33 std::string getanswers1(void); 34 std::string getanswers2(void); 32 35 33 int getnumOptions();34 std::vector<std::string> options;*/36 NextQuestion compare(); 37 35 38 36 39 //Event … … 40 43 41 44 private: 45 std::string a1; 46 std::string a2; 47 std::vector<NextQuestion*> possibleQuestions; 48 49 42 50 std::string question; 43 51 DialogueManager* m;
Note: See TracChangeset
for help on using the changeset viewer.