[Orxonox-commit 6785] r11413 - in code/branches/Dialogue_FS17: data/gui/scripts data/levels src/modules/dialogue

rrogge at orxonox.net rrogge at orxonox.net
Thu May 4 16:11:36 CEST 2017


Author: rrogge
Date: 2017-05-04 16:11:36 +0200 (Thu, 04 May 2017)
New Revision: 11413

Modified:
   code/branches/Dialogue_FS17/data/gui/scripts/Dialogue.lua
   code/branches/Dialogue_FS17/data/levels/events.oxw
   code/branches/Dialogue_FS17/src/modules/dialogue/DialogueManager.cc
   code/branches/Dialogue_FS17/src/modules/dialogue/DialogueManager.h
   code/branches/Dialogue_FS17/src/modules/dialogue/NextQuestion.cc
   code/branches/Dialogue_FS17/src/modules/dialogue/NextQuestion.h
Log:
Buttons

Modified: code/branches/Dialogue_FS17/data/gui/scripts/Dialogue.lua
===================================================================
--- code/branches/Dialogue_FS17/data/gui/scripts/Dialogue.lua	2017-05-04 13:17:59 UTC (rev 11412)
+++ code/branches/Dialogue_FS17/data/gui/scripts/Dialogue.lua	2017-05-04 14:11:36 UTC (rev 11413)
@@ -92,10 +92,25 @@
     P.wrapper = winMgr:createWindow("MenuWidgets/ScrollablePane", "orxonox/Dialogue/Inventory/Wrapper")
     P.wrapper:setSize(CEGUI.UVector2(CEGUI.UDim(1,0),CEGUI.UDim(1,0)))
     root:addChildWindow(P.wrapper)
-    root:addChild(answerButton)
     
-   
+    
+    local detailsButton = winMgr:createWindow("MenuWidgets/Button", "/DetailsButton")
+    local a1 = orxonox.DialogueManager:getInstance():getanswers1()
+    detailsButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0.3, P.imageHeight+2*P.buttonWidth),CEGUI.UDim(0, (P.imageHeight-P.textHeight)/2)))
+    detailsButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.buttonWidth), CEGUI.UDim(0, P.textHeight)))
+    detailsButton:setText(a1)
+    orxonox.GUIManager:subscribeEventHelper(detailsButton, "Clicked", P.name ..".a1Button_clicked")
+    root:addChildWindow(detailsButton)
 
+    local a2Button = winMgr:createWindow("MenuWidgets/Button", "/a2Button")
+    local a2 = orxonox.DialogueManager:getInstance():getanswers2()
+    a2Button:setPosition(CEGUI.UVector2(CEGUI.UDim(0.3, P.imageHeight+40+2*P.buttonWidth),CEGUI.UDim(0, (P.imageHeight-P.textHeight)/2)))
+    a2Button:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.buttonWidth), CEGUI.UDim(0, P.textHeight)))
+    a2Button:setText(a2)
+    orxonox.GUIManager:subscribeEventHelper(a2Button, "Clicked", P.name ..".a2Button_clicked")
+    root:addChildWindow(a2Button)
+
+
 end
 
 
@@ -118,8 +133,12 @@
 
 
 
-function P.InventoryBackButton_clicked(e)
-    orxonox.CommandExecutor:execute("OrxonoxOverlay toggleVisibility Dialogue")
+function P.a1Button_clicked(e)
+    orxonox.DialogueManager:getInstance():a1clicked()
 end
 
+function P.a2Button_clicked(e)
+    orxonox.DialogueManager:getInstance():a2clicked()
+end
+
 return P

Modified: code/branches/Dialogue_FS17/data/levels/events.oxw
===================================================================
--- code/branches/Dialogue_FS17/data/levels/events.oxw	2017-05-04 13:17:59 UTC (rev 11412)
+++ code/branches/Dialogue_FS17/data/levels/events.oxw	2017-05-04 14:11:36 UTC (rev 11413)
@@ -56,9 +56,13 @@
       works with all amounts of objects from zero to infinity. In the examples I used two objects each.
     -->
 
-<DistanceTrigger name="test" position="0,0,0" target="Pawn" distance=25 stayActive="true"/>
+    <DistanceTrigger name="test" position="0,0,0" target="Pawn" distance=25 stayActive="true" />
     <Backlight position="0,0,0" visible=true frequency=0.6 amplitude=3 material="Flares/lensflare" colour="1,0,1"/>
-    <NextQuestion question="Hello World3">
+    <NextQuestion  question="Continue?" a1="yes" a2="no" >
+      <!-- <possibleQuestions> 
+        <NextQuestion  question="Are you sure?" a1="yep let me continue" a2="no actually not" />
+        <NextQuestion  question="Why?" a1="Got a dentist's appointment" a2="this sucks" />
+      </possibleQuestions>     --> 
       <events>
         <execute>
            <EventListener event="test" />

Modified: code/branches/Dialogue_FS17/src/modules/dialogue/DialogueManager.cc
===================================================================
--- code/branches/Dialogue_FS17/src/modules/dialogue/DialogueManager.cc	2017-05-04 13:17:59 UTC (rev 11412)
+++ code/branches/Dialogue_FS17/src/modules/dialogue/DialogueManager.cc	2017-05-04 14:11:36 UTC (rev 11413)
@@ -35,9 +35,8 @@
     
 
     void DialogueManager::setquestion(std::string q){
-		orxout() << "setquestion" << endl;
 		question=q;
-		orxout() << "Question is " << question;
+		
 	}
 
 	std::string DialogueManager::getquestion(void){
@@ -44,6 +43,34 @@
 		orxout() << question << endl;
 		return question;
 	}
+	void DialogueManager::setanswers1(std::string a1){
+		orxout() << "setanswers1" << endl;
+		this->a1=a1;
+		orxout() << "A1 is " << a1;
+				}
+
+	void DialogueManager::setanswers2(std::string a2){
+		this->a2=a2;
+				}
+
+	
+
+	std::string DialogueManager::getanswers1(void){
+		orxout() << "getanswers1" << endl;
+		return a1;
+	}
+
+	std::string DialogueManager::getanswers2(void){
+		return a2;
+	}
+	bool DialogueManager::a1clicked(void){
+		orxout() << "a1 clicked" << endl;
+		return true;
+	}
+	bool DialogueManager::a2clicked(void){
+		orxout() << "a2 clicked" << endl;
+		return true;
+	}
 	/*void DialogueManager::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     {
         SUPER(DialogueManager, XMLPort, xmlelement, mode);
@@ -59,12 +86,7 @@
 
 	
 
-	void DialogueManager::setanswers(std::string option1, std::string option2, std::string option3){
-		options.at(0)=option1;
-		options.at(1)=option2;
-		options.at(2)=option3;
-	}
-
+	
 	vector<std::string> DialogueManager::getanswers(void){
 		return options;
 	}

Modified: code/branches/Dialogue_FS17/src/modules/dialogue/DialogueManager.h
===================================================================
--- code/branches/Dialogue_FS17/src/modules/dialogue/DialogueManager.h	2017-05-04 13:17:59 UTC (rev 11412)
+++ code/branches/Dialogue_FS17/src/modules/dialogue/DialogueManager.h	2017-05-04 14:11:36 UTC (rev 11413)
@@ -14,6 +14,7 @@
 #include "core/EventIncludes.h"
 
 
+
 namespace orxonox //tolua_export
 
 {//tolua_export
@@ -34,9 +35,12 @@
 		std::string getquestion(void); //tolua_export
 		
 
-		
-	
-
+		void setanswers1(std::string a1); //tolua_export
+		void setanswers2(std::string a2); //tolua_export
+		std::string getanswers1(void); //tolua_export
+		std::string getanswers2(void); //tolua_export
+		bool a1clicked(void); //tolua_export
+		bool a2clicked(void); //tolua_export
 			/*std::string setnpc(std::string npc);
 
 			void setanswers(std::string option1, std::string option2, std::string option3);
@@ -51,6 +55,8 @@
 		
 */
 private:
+	std::string a1;
+	std::string a2;
 	std::string question;
 	static DialogueManager* singletonPtr_s;
 

Modified: code/branches/Dialogue_FS17/src/modules/dialogue/NextQuestion.cc
===================================================================
--- code/branches/Dialogue_FS17/src/modules/dialogue/NextQuestion.cc	2017-05-04 13:17:59 UTC (rev 11412)
+++ code/branches/Dialogue_FS17/src/modules/dialogue/NextQuestion.cc	2017-05-04 14:11:36 UTC (rev 11413)
@@ -1,4 +1,4 @@
-#include <vector>
+//#include <vector>
 #include <string>
 #include "core/CoreIncludes.h"
 #include "core/GUIManager.h"
@@ -18,7 +18,6 @@
         orxout() << "Klasse aufgerufen" << endl;
          DialogueManager* d = new DialogueManager(context);
         
-
     }
 
 	void NextQuestion::setquestion(std::string question){
@@ -31,15 +30,32 @@
 	}
 
 	
-	//
+	bool NextQuestion::addposQuestion(NextQuestion* nq){
+		
+		possibleQuestions.push_back(nq);
+		return true;
+	}
 
+	const NextQuestion* NextQuestion::getposQuestion(unsigned int i) const
+    {
+        for (NextQuestion* effect : this->possibleQuestions)
+        {
+            if(i == 0)
+               return effect;
+            i--;
+        }
+        return nullptr; }
 	
-	//XML and Event shit
+	//XML and Event stuff
 	void NextQuestion::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     {
         SUPER(NextQuestion, XMLPort, xmlelement, mode);
 
         XMLPortParam(NextQuestion, "question", setquestion, getquestion, xmlelement, mode);
+        XMLPortParam(NextQuestion, "a1", setanswers1, getanswers1, xmlelement, mode);
+        XMLPortParam(NextQuestion, "a2", setanswers2, getanswers2, xmlelement, mode);
+        XMLPortObject(NextQuestion, NextQuestion, "possibleQuestions", addposQuestion, getposQuestion, xmlelement, mode);
+       
     }
 	bool NextQuestion::execute(bool bTriggered, BaseObject* trigger)
     {  
@@ -56,6 +72,8 @@
         DialogueManager& m = DialogueManager::getInstance();
         	
         m.setquestion(question);
+        m.setanswers1(a1);
+        m.setanswers2(a2);
         orxout() << " 1 " << endl;
 
        
@@ -70,18 +88,36 @@
 
         XMLPortEventSink(NextQuestion, BaseObject, "execute", execute, xmlelement, mode); 
     }
-	/*void NextQuestion::setanswers(std::string option1, std::string option2, std::string option3){
-		options.at(0)=option1;
-		options.at(1)=option2;
-		options.at(2)=option3;
+
+
+	void NextQuestion::setanswers1(std::string a1){
+		this->a1=a1;
+				}
+
+	void NextQuestion::setanswers2(std::string a2){
+		this->a2=a2;
+				}
+
+	
+
+	std::string NextQuestion::getanswers1(void){
+		return a1;
 	}
 
-	vector<std::string> NextQuestion::getanswers(void){
-		return options;
+	std::string NextQuestion::getanswers2(void){
+		return a2;
 	}
 
-	int NextQuestion::getnumOptions(){
-		return options.size();
-	}*/
+	NextQuestion NextQuestion::compare(){
+		DialogueManager& m = DialogueManager::getInstance();
+		if(m.a1clicked()){
+			return *possibleQuestions[0];
+		}
 
+		else if(m.a2clicked()){
+			return *possibleQuestions[1];
+		}
+	}
+
+
 }
\ No newline at end of file

Modified: code/branches/Dialogue_FS17/src/modules/dialogue/NextQuestion.h
===================================================================
--- code/branches/Dialogue_FS17/src/modules/dialogue/NextQuestion.h	2017-05-04 13:17:59 UTC (rev 11412)
+++ code/branches/Dialogue_FS17/src/modules/dialogue/NextQuestion.h	2017-05-04 14:11:36 UTC (rev 11413)
@@ -1,4 +1,4 @@
-#include <vector>
+//#include <vector>
 #include <string>
 #include "core/class/Identifier.h"
 #include "OrxonoxPrereqs.h"
@@ -22,16 +22,19 @@
 		std::string getquestion(void);
 
 
-		
+		bool addposQuestion(NextQuestion* nq);
+		const NextQuestion* getposQuestion(unsigned int index) const;
  
 		
 		virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
 
-		/*void setanswers(std::string option1, std::string option2, std::string option3);
-		std::vector <std::string> getanswers(void);
+		void setanswers1(std::string a1);
+		void setanswers2(std::string a2);
+		std::string getanswers1(void);
+		std::string getanswers2(void);
 
-		int getnumOptions();
-		std::vector<std::string> options;*/
+		NextQuestion compare();
+		
 
 		//Event
 		virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
@@ -39,6 +42,11 @@
 
 		
 	private:
+		std::string a1;
+		std::string a2;
+		std::vector<NextQuestion*> possibleQuestions;
+
+
 		std::string question;
 		DialogueManager* m;
 



More information about the Orxonox-commit mailing list