[Orxonox-commit 6808] r11435 - in code/branches/Dialogue_FS17: data/gui/scripts data/levels data/tcl src/modules/dialogue

rrogge at orxonox.net rrogge at orxonox.net
Fri May 26 15:40:08 CEST 2017


Author: rrogge
Date: 2017-05-26 15:40:04 +0200 (Fri, 26 May 2017)
New Revision: 11435

Added:
   code/branches/Dialogue_FS17/data/levels/DialogueShowcase.oxw
Modified:
   code/branches/Dialogue_FS17/data/gui/scripts/Dialogue.lua
   code/branches/Dialogue_FS17/data/levels/emptyLevel.oxw
   code/branches/Dialogue_FS17/data/tcl/core
   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:
Code aufgeraeumt

Modified: code/branches/Dialogue_FS17/data/gui/scripts/Dialogue.lua
===================================================================
--- code/branches/Dialogue_FS17/data/gui/scripts/Dialogue.lua	2017-05-26 13:26:34 UTC (rev 11434)
+++ code/branches/Dialogue_FS17/data/gui/scripts/Dialogue.lua	2017-05-26 13:40:04 UTC (rev 11435)
@@ -1,37 +1,4 @@
---[[local P = createMenuSheet("Dialogue Window")
 
-function P.onLoad()
-	P.createWindow()
-	P.showing = true    
-end
- function function_name( ... )
- 	-- body
- end
-
-
-
-
-function P.createWindow()
-    
-    local question = orxonox.DialogueManager:getInstance():getquestion()
-    local default = (winMgr:createWindow("DefaultWindow"))
-    default:setText(question)
-    default:setProperty("UnifiedMaxSize", "{{1,0},{1,0}}")
-    default:setProperty("UnifiedAreaRect", "{{0,0},{0,0},{1,0},{1,0}}")
-    
-    
-
-
-    
-end
-local numOptions = DialogueManager:getnumOptions()
-    local counter = 1
-    local offset = 0
-    --create and name buttons while there are still options
-    while counter <= numOptions do
-        
-        
-    end]]
 -- Dialogue.lua
 
 local P = createMenuSheet("Dialogue")
@@ -50,8 +17,6 @@
 P.buttonWidth = 85
 
 function P.onLoad()
-
-	orxout("loading")
     P.wrapper = nil
     P.detailsWindows = {}
     P.detailPickups = {}
@@ -59,7 +24,6 @@
 end
 
 function P.onShow()
-	orxout("showing")
     orxonox.CommandExecutor:execute("setTimeFactor 0")
     P.createInventory()
     P.showing = true
@@ -73,7 +37,6 @@
 end
 
 function P.update()
-    orxout("UPDATING")
     P.updateInventory()
     if P.showing == false then
         return
@@ -103,8 +66,8 @@
     
     detailsButton = winMgr:createWindow("MenuWidgets/Button", "/DetailsButton")
     local a1 = orxonox.DialogueManager:getInstance():getanswers1()
-    detailsButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0.1, 0),CEGUI.UDim(0.25, 0)))
-    detailsButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, 575), CEGUI.UDim(0, P.textHeight)))
+    detailsButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0.1, 0),CEGUI.UDim(0.25, (P.imageHeight-P.textHeight)/2)))
+    detailsButton:setSize(CEGUI.UVector2(CEGUI.UDim(0.8, 0), CEGUI.UDim(0, P.textHeight)))
     detailsButton:setText(a1)
     orxonox.GUIManager:subscribeEventHelper(detailsButton, "Clicked", P.name ..".a1Button_clicked")
     P.wrapper:addChildWindow(detailsButton)
@@ -111,8 +74,8 @@
 
     a2Button = winMgr:createWindow("MenuWidgets/Button", "/a2Button")
     local a2 = orxonox.DialogueManager:getInstance():getanswers2()
-    a2Button:setPosition(CEGUI.UVector2(CEGUI.UDim(0.1, 0),CEGUI.UDim(0.4, 0)))
-    a2Button:setSize(CEGUI.UVector2(CEGUI.UDim(0, 575), CEGUI.UDim(0, P.textHeight)))
+    a2Button:setPosition(CEGUI.UVector2(CEGUI.UDim(0.1, 0),CEGUI.UDim(0.4, (P.imageHeight-P.textHeight)/2)))
+    a2Button:setSize(CEGUI.UVector2(CEGUI.UDim(0.8, 0), CEGUI.UDim(0, P.textHeight)))
     a2Button:setText(a2)
     orxonox.GUIManager:subscribeEventHelper(a2Button, "Clicked", P.name ..".a2Button_clicked")
     P.wrapper:addChildWindow(a2Button)
@@ -146,7 +109,7 @@
             P.destroyDetailWindow(k)
         end
     end
-    orxonox.DialogueManager:getInstance():clean()
+    
 end
 
 

Added: code/branches/Dialogue_FS17/data/levels/DialogueShowcase.oxw
===================================================================
--- code/branches/Dialogue_FS17/data/levels/DialogueShowcase.oxw	                        (rev 0)
+++ code/branches/Dialogue_FS17/data/levels/DialogueShowcase.oxw	2017-05-26 13:40:04 UTC (rev 11435)
@@ -0,0 +1,79 @@
+<LevelInfo
+ name = "DialogueShowcase"
+ description = "A level to show and test the functionality of the Dialogue module."
+ tags = "test"
+ screenshot = "emptylevel.png"
+/>
+
+<?lua
+  include("stats.oxo")
+  include("HUDTemplates3.oxo")
+  include("templates/lodInformation.oxt")
+  include("templates/HeavyCruiser.oxt")
+?>
+
+<?lua
+  include("templates/spaceshipEscort.oxt")
+  include("templates/endurancetest_template.oxt")
+?>
+
+<Level>
+  <templates>
+    <Template link=lodtemplate_default />
+  </templates>
+  <?lua include("includes/notifications.oxi") ?>
+  
+
+  <Scene
+    ambientlight = "0.8, 0.8, 0.8"
+    skybox       = "Orxonox/Starbox"
+  >
+ <DistanceTrigger name="test" position="100,0,100" target="Pawn" distance=25 stayActive="true" />
+    <Backlight position="100,0,100" visible=true frequency=0.6 amplitude=3 material="Flares/lensflare" colour="1,0,1"/>
+    
+    <NextQuestion  question="Unknown Spaceship Transmission: Who goes there?" a1="(say your name)" a2="None of your business I'm afraid." >
+     <possibleQuestions> 
+        <NextQuestion  question="You're not cleared for this area, turn back." a1="Doesn't look too exciting here anyways." a2="You gotta make me try...(attack)" />
+        <NextQuestion  question="I'll make it my business. Only military allowed in this area." a1="Whoops, didn't know that, I'll be on my way then." a2="Got an important message for Sgt Smith though." >
+        <possibleQuestions>
+          <NextQuestion  question="Make sure I don't have to see your ugly face again." a1="...thanks, bye." a2="I'll think about it." />
+          <NextQuestion  question="Oh why didn't you say that in the first place? Off you go." a1="Thanks mate." a2="Just don't be so rude next time." />
+        </possibleQuestions>
+      </NextQuestion>
+      </possibleQuestions>    
+      <events>
+        <execute>
+           <EventListener event="test" />
+        </execute>
+      </events>
+    </NextQuestion>
+
+    <DistanceTrigger name="test1" position="100,0,-100" target="Pawn" distance=25 stayActive="true" />
+    <Backlight position="100,0,-100" visible=true frequency=0.6 amplitude=3 material="Flares/lensflare" colour="1,1,1"/>
+    
+    <NextQuestion  question="Hey,  sorry to bother you,  could you help me with something?" a1="Yeah sure." a2="Nope get lost." >
+     <possibleQuestions> 
+        <NextQuestion  question="Do you like fish" a1="...yes?" a2="This is wasting my time." >
+        <possibleQuestions>
+          <NextQuestion  question="Splendid! Would you like your ship to look like one?" a1="..." a2="I'm going now,  okay?" />
+          <NextQuestion  question="Turtles then?" a1="..." a2="Im going now,  okay?" />
+        </possibleQuestions>
+        </NextQuestion>
+        <NextQuestion  question="I can pay you know." a1="Got enough money." a2="...are you deaf? Bye."/>
+      </possibleQuestions>    
+      <events>
+        <execute>
+           <EventListener event="test1" />
+        </execute>
+      </events>
+    </NextQuestion>
+
+    
+
+    <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
+    <SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipescort />
+
+    
+    
+  </Scene>
+</Level>

Modified: code/branches/Dialogue_FS17/data/levels/emptyLevel.oxw
===================================================================
--- code/branches/Dialogue_FS17/data/levels/emptyLevel.oxw	2017-05-26 13:26:34 UTC (rev 11434)
+++ code/branches/Dialogue_FS17/data/levels/emptyLevel.oxw	2017-05-26 13:40:04 UTC (rev 11435)
@@ -28,42 +28,28 @@
     ambientlight = "0.8, 0.8, 0.8"
     skybox       = "Orxonox/Starbox"
   >
- <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,0"/>
-    <DialogueManager question="Hello World3">
-      <events>
-        <execute>
-           <EventListener event="test" />
-        </execute>
-      </events>
-    </DialogueManager>
+ 
 
-    <!--<DialogueManager firstquestion="hello world">
-      <options>
-        <NextQuestion answer="ja" question="question?">
-          <options>
-            <NextQuestion answer="" question="">
-            </NextQuestion>
-          </options>
-        </NextQuestion>
-       <events>
+    <DistanceTrigger name="test" position="100,0,100" target="Pawn" distance=25 stayActive="true" />
+    <Backlight position="100,0,100" visible=true frequency=0.6 amplitude=3 material="Flares/lensflare" colour="1,0,1"/>
+    
+    <NextQuestion  question="Your question" a1="First answer" a2="Second answer" >
+      <possibleQuestions>
+          <NextQuestion  question="Your next question if a1 was chosen" a1="First answer" a2="Second answer" />
+          <NextQuestion  question="Your next question if a2 was chosen." a1="First answer" a2="Second answer" />
+        </possibleQuestions>
+    <events>
         <execute>
            <EventListener event="test" />
         </execute>
-      </events>
-    </DialogueManager>
-  -->
+    </events>
+    </NextQuestion>
 
-
     <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
     <SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipescort />
 
-    <ModularSpaceShip velocity= "20,0,0" position="0,0,200" lookat= "0,0,0" health="1000" maxhealth="1000" initialhealth="1000">
-      <templates>
-        <Template link=endurance />
-      </templates>
-    </ModularSpaceShip>
     
+    
   </Scene>
 </Level>
 

Modified: code/branches/Dialogue_FS17/data/tcl/core
===================================================================
(Binary files differ)

Modified: code/branches/Dialogue_FS17/src/modules/dialogue/DialogueManager.cc
===================================================================
--- code/branches/Dialogue_FS17/src/modules/dialogue/DialogueManager.cc	2017-05-26 13:26:34 UTC (rev 11434)
+++ code/branches/Dialogue_FS17/src/modules/dialogue/DialogueManager.cc	2017-05-26 13:40:04 UTC (rev 11435)
@@ -17,26 +17,17 @@
 	ManageScopedSingleton(DialogueManager, ScopeID::ROOT, false);
 	
 
-	//DialogueManager* DialogueManager::singletonPtr_s =nullptr;
+	
+	DialogueManager::DialogueManager(){}
+	
 
-	DialogueManager::DialogueManager(){
-		orxout() << "Dialog Konstruktor" << endl;
-		//RegisterObject(DialogueManager);
-		
-	}
 	
-
-	/**
-     * @brief set the config values in the orxonox.ini file
-     */
     
 
 	void DialogueManager::registerquestion(NextQuestion* nq){
 		if(allQuestions.size()==0) {
 			orxout(internal_info) << "At least one NextQuestion has to be set." << endl;
-		} else  {
-			currentQuestion = allQuestions[0];
-		}
+		} 
 		allQuestions.push_back(nq);
 			orxout(internal_info) << "qsize " << allQuestions.size();
 
@@ -52,13 +43,11 @@
 	}
 
 	std::string DialogueManager::getquestion(void){
-		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){
@@ -68,7 +57,6 @@
 	
 
 	std::string DialogueManager::getanswers1(void){
-		orxout() << "getanswers1" << endl;
 		return a1;
 	}
 
@@ -75,9 +63,9 @@
 	std::string DialogueManager::getanswers2(void){
 		return a2;
 	}
+
 	void DialogueManager::a1clicked(void){
 		
-		
 		currentQuestion = currentQuestion->possibleQuestions[0];
 		update(currentQuestion);
 
@@ -84,47 +72,21 @@
 		
 	}
 	void DialogueManager::a2clicked(void){
-		orxout() << "a2 clicked" << endl;
-
+		
 		currentQuestion = currentQuestion->possibleQuestions[1];
 		update(currentQuestion);
+	}
 
-		
-	}
 	 void DialogueManager::update(NextQuestion* nq){
 	 	this->setquestion(nq->getquestion());
 	 	this->setanswers1(nq->getanswers1());
 	 	this->setanswers2(nq->getanswers2());
-	 	depth=depth+1;
-	 	
-	 	
 	 }
-	void DialogueManager::clean(){
-		orxout() <<" depth " << depth << endl;
-		//allQuestions.at(2*depth+1);
-	}
+
 	bool DialogueManager::theEnd(){
 	if((currentQuestion->possibleQuestions).empty()) {
-		orxout() << "endtrue" << endl;
 		return true;}
 	else return false;
 	}
 
-	
-
-	/*
-	
-	
-	
-
-	
-	vector<std::string> DialogueManager::getanswers(void){
-		return options;
-	}
-
-	int DialogueManager::getnumOptions(){
-		return options.size();
-	}
-
-	*/
 }
\ No newline at end of file

Modified: code/branches/Dialogue_FS17/src/modules/dialogue/DialogueManager.h
===================================================================
--- code/branches/Dialogue_FS17/src/modules/dialogue/DialogueManager.h	2017-05-26 13:26:34 UTC (rev 11434)
+++ code/branches/Dialogue_FS17/src/modules/dialogue/DialogueManager.h	2017-05-26 13:40:04 UTC (rev 11435)
@@ -11,7 +11,6 @@
 #include "util/Singleton.h"
 #include <string>
 #include <vector>
-//#include "OrxonoxPrereqs.h"
 #include "core/config/Configurable.h"
 #include "core/XMLPort.h"
 #include "core/EventIncludes.h"
@@ -31,34 +30,43 @@
 	
 		public:
 		
-
 		DialogueManager(); 
 		
 
 		static DialogueManager& getInstance() { return Singleton<DialogueManager>::getInstance(); } //tolua_export
 		
+
 		void setquestion(std::string question); //tolua_export
 		std::string getquestion(void); //tolua_export
 		
-		void registerquestion(NextQuestion* nq);
+		
 		void setanswers1(std::string a1); //tolua_export
+		std::string getanswers1(void); //tolua_export
+		
 		void setanswers2(std::string a2); //tolua_export
-		std::string getanswers1(void); //tolua_export
 		std::string getanswers2(void); //tolua_export
+		
+		void setCurrentQuestion(NextQuestion* q);
+
+		//Sets the current Question to the question corresponding to the first/second answer  
 		void a1clicked(void); //tolua_export
 		void a2clicked(void); //tolua_export
+		
+		//Checks whether there are any more Questions to come
 		bool theEnd(); //tolua_export 
+
+		//Sets question and a1, a2 for new currentQuestion
 		void update(NextQuestion* nq);
-		void clean(); //tolua_export
-		void setCurrentQuestion(NextQuestion* q);
 
+		//Is executed whenever a NextQuestion is created and pushes all NextQuestion into the allQuestion vector.
+		void registerquestion(NextQuestion* nq);
+
 private:
-	NextQuestion* currentQuestion;
+	NextQuestion* currentQuestion; //The Question which is currently displayed
 	std::vector<NextQuestion*> allQuestions;
-	std::string a1;
-	std::string a2;
+	std::string a1; //answer on first button
+	std::string a2; //answer on second button
 	std::string question;
-	int depth = 0;
 	static DialogueManager* singletonPtr_s;
 
 	};//tolua_export

Modified: code/branches/Dialogue_FS17/src/modules/dialogue/NextQuestion.cc
===================================================================
--- code/branches/Dialogue_FS17/src/modules/dialogue/NextQuestion.cc	2017-05-26 13:26:34 UTC (rev 11434)
+++ code/branches/Dialogue_FS17/src/modules/dialogue/NextQuestion.cc	2017-05-26 13:40:04 UTC (rev 11435)
@@ -16,10 +16,10 @@
 	NextQuestion::NextQuestion(Context* context) : BaseObject(context)
     {
         RegisterObject(NextQuestion);
-        orxout() << "Klasse aufgerufen" << endl;
+
         DialogueManager& m = DialogueManager::getInstance();
         m.registerquestion(this);
-       //possibleQuestions=nullptr;
+       
         
     }
 
@@ -28,7 +28,6 @@
 	}
 
 	std::string NextQuestion::getquestion(void){
-		orxout() << question;
 		return question;
 	}
 
@@ -50,7 +49,7 @@
         return nullptr;
          }
 	
-	//XML and Event stuff
+	
 	void NextQuestion::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     {
         SUPER(NextQuestion, XMLPort, xmlelement, mode);
@@ -63,23 +62,14 @@
     }
 	bool NextQuestion::execute(bool bTriggered, BaseObject* trigger)
     {  
-        //if(!bTriggered) return false;
-    	
         
-    	
-
-        orxout() << "bTriggered is " << bTriggered << endl;
-
-        //for (DialogueManager* hud : ObjectList<DialogueManager>())
-            //m = hud;
-
-        DialogueManager& m = DialogueManager::getInstance();
+    	DialogueManager& m = DialogueManager::getInstance();
         	
         m.setquestion(question);
         m.setCurrentQuestion(this);
         m.setanswers1(a1);
         m.setanswers2(a2);
-        orxout() << " 1 " << endl;
+       
 
        
         OrxonoxOverlay::showOverlay("Dialogue");
@@ -113,17 +103,9 @@
 		return a2;
 	}
 
-	std::vector<NextQuestion*> NextQuestion::retposQues(){
-		//if(possibleQuestions.size()==0) return NULL;
 	
-		orxout() << "SIZE" << possibleQuestions.size() << endl;
-		return possibleQuestions;
-	}
 
 
-	/*
 
-	}*/
 
-
 }
\ 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-26 13:26:34 UTC (rev 11434)
+++ code/branches/Dialogue_FS17/src/modules/dialogue/NextQuestion.h	2017-05-26 13:40:04 UTC (rev 11435)
@@ -2,7 +2,7 @@
 #define _NextQuestion_H__
 
 
-//#include <vector>
+
 #include <string>
 #include "core/class/Identifier.h"
 #include "OrxonoxPrereqs.h"
@@ -24,27 +24,28 @@
 		void setquestion(std::string question);
 		std::string getquestion(void);
 
-
-		bool addposQuestion(NextQuestion* nq);
-		const NextQuestion* getposQuestion(unsigned int index) const;
- 
-		
-		virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
-
 		void setanswers1(std::string a1);
 		void setanswers2(std::string a2);
 		std::string getanswers1(void);
 		std::string getanswers2(void);
 
-		NextQuestion compare();
 		
+		
 
-		//Event
+		//XMLEventPort for Event that first triggers the Dialogue
 		virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
+
+		//XMLPort for setting questions and answers and the vector possibleQuestions
+		virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+		bool addposQuestion(NextQuestion* nq);
+		const NextQuestion* getposQuestion(unsigned int index) const;
+
+		//Sets very first currentQuestion in the DialogueManager when the event is triggered
 		bool execute(bool bTriggered, BaseObject* trigger);
 
 		std::vector<NextQuestion*> possibleQuestions;
-		std::vector<NextQuestion*> retposQues();
+	
 	private:
 		std::string a1;
 		std::string a2;



More information about the Orxonox-commit mailing list