[Orxonox-commit 6765] r11393 - in code/branches/Dialogue_FS17: data/levels src/modules/dialogue

rrogge at orxonox.net rrogge at orxonox.net
Thu Apr 6 15:40:23 CEST 2017


Author: rrogge
Date: 2017-04-06 15:40:23 +0200 (Thu, 06 Apr 2017)
New Revision: 11393

Added:
   code/branches/Dialogue_FS17/src/modules/dialogue/NextQuestion.cc
   code/branches/Dialogue_FS17/src/modules/dialogue/NextQuestion.h
Modified:
   code/branches/Dialogue_FS17/data/levels/emptyLevel.oxw
   code/branches/Dialogue_FS17/src/modules/dialogue/DialogueManager.cc
   code/branches/Dialogue_FS17/src/modules/dialogue/DialogueManager.h
Log:
Singleton funktioniert

Modified: code/branches/Dialogue_FS17/data/levels/emptyLevel.oxw
===================================================================
--- code/branches/Dialogue_FS17/data/levels/emptyLevel.oxw	2017-04-06 13:32:35 UTC (rev 11392)
+++ code/branches/Dialogue_FS17/data/levels/emptyLevel.oxw	2017-04-06 13:40:23 UTC (rev 11393)
@@ -28,8 +28,33 @@
     ambientlight = "0.8, 0.8, 0.8"
     skybox       = "Orxonox/Starbox"
   >
-  <DialogueManager question="Wazzup">
-  </DialogueManager>
+ <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>
+        <execute>
+           <EventListener event="test" />
+        </execute>
+      </events>
+    </DialogueManager>
+  -->
+
+
     <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 />
 

Modified: code/branches/Dialogue_FS17/src/modules/dialogue/DialogueManager.cc
===================================================================
--- code/branches/Dialogue_FS17/src/modules/dialogue/DialogueManager.cc	2017-04-06 13:32:35 UTC (rev 11392)
+++ code/branches/Dialogue_FS17/src/modules/dialogue/DialogueManager.cc	2017-04-06 13:40:23 UTC (rev 11393)
@@ -9,25 +9,29 @@
 #include "DialoguePrereqs.h"
 #include <vector>
 #include <string>
+#include "core/XMLPort.h"
 
+
 namespace orxonox {
-	ManageScopedSingleton(DialogueManager, ScopeID::ROOT, false);
-	RegisterClassNoArgs(DialogueManager);
+	//ManageScopedSingleton(DialogueManager, ScopeID::ROOT, false);
+	RegisterAbstractClass(DialogueManager).inheritsFrom<Configurable>();
 
-	DialogueManager::DialogueManager(){
+
+
+	DialogueManager* DialogueManager::singletonPtr_s =nullptr;
+
+	DialogueManager::DialogueManager(Context* context): BaseObject(context){
 		RegisterObject(DialogueManager);
 		this->setConfigValues();
+		
 
 	}
 	
+
 	/**
      * @brief set the config values in the orxonox.ini file
      */
-    void DialogueManager::setConfigValues()
-    {
-        //SetConfigValue(question,std::string).description("Question");
-        
-    }
+    
 
     void DialogueManager::setquestion(std::string question){
 		question=question;
@@ -42,6 +46,23 @@
 
         XMLPortParam(DialogueManager, "question", setquestion, getquestion, xmlelement, mode);
     }
+
+	bool DialogueManager::execute(bool bTriggered, BaseObject* trigger)
+    {  
+        if(!bTriggered) return false;
+
+        orxout() << "bTriggered is " << bTriggered;
+        //orxout() << " 1 " << mystring << endl;
+        return false;
+    }
+
+    void DialogueManager::XMLEventPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(DialogueManager, XMLEventPort, xmlelement, mode);
+
+        XMLPortEventSink(DialogueManager, BaseObject, "execute", execute, xmlelement, mode); 
+    }
+
 	/*std::string DialogueManager::setnpc(std::string npc){
 		return npc;
 	}

Modified: code/branches/Dialogue_FS17/src/modules/dialogue/DialogueManager.h
===================================================================
--- code/branches/Dialogue_FS17/src/modules/dialogue/DialogueManager.h	2017-04-06 13:32:35 UTC (rev 11392)
+++ code/branches/Dialogue_FS17/src/modules/dialogue/DialogueManager.h	2017-04-06 13:40:23 UTC (rev 11393)
@@ -12,25 +12,34 @@
 #include "OrxonoxPrereqs.h"
 #include "core/config/Configurable.h"
 #include "core/XMLPort.h"
+#include "core/EventIncludes.h"
 
 //tolua_begin
 namespace orxonox
 //tolua_end
 {//toluaexport
-	class _OrxonoxExport DialogueManager : public Singleton<DialogueManager>, public Configurable
+	class _OrxonoxExport DialogueManager : public Singleton<DialogueManager>, public BaseObject
 	{
 		friend class Singleton<DialogueManager>;
 		//tolua_begin
 		public:
 
-		DialogueManager(); // tolua_export
+		DialogueManager(Context* context); // tolua_export
+		
+
 		static DialogueManager& getInstance() { return Singleton<DialogueManager>::getInstance(); } 
-		void setConfigValues();
+		
 		virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
 
-			void setquestion(std::string question);
-			std::string getquestion(void);
+		void setquestion(std::string question);
+		std::string getquestion(void);
 
+
+		virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
+		bool execute(bool bTriggered, BaseObject* trigger);
+
+	
+
 			/*std::string setnpc(std::string npc);
 
 			void setanswers(std::string option1, std::string option2, std::string option3);

Added: code/branches/Dialogue_FS17/src/modules/dialogue/NextQuestion.cc
===================================================================
--- code/branches/Dialogue_FS17/src/modules/dialogue/NextQuestion.cc	                        (rev 0)
+++ code/branches/Dialogue_FS17/src/modules/dialogue/NextQuestion.cc	2017-04-06 13:40:23 UTC (rev 11393)
@@ -0,0 +1,27 @@
+#include <vector>
+#include <string>
+
+#include "NextQuestion.h"
+#include "core/XMLPort.h"
+
+namespace orxonox{
+
+	RegisterClass(NextQuestion);
+
+	vector<NextQuestion> nextquestion;
+
+	void NextQuestion::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> NextQuestion::getanswers(void){
+		return options;
+	}
+
+	int NextQuestion::getnumOptions(){
+		return options.size();
+	}
+
+}
\ No newline at end of file

Added: code/branches/Dialogue_FS17/src/modules/dialogue/NextQuestion.h
===================================================================
--- code/branches/Dialogue_FS17/src/modules/dialogue/NextQuestion.h	                        (rev 0)
+++ code/branches/Dialogue_FS17/src/modules/dialogue/NextQuestion.h	2017-04-06 13:40:23 UTC (rev 11393)
@@ -0,0 +1,12 @@
+#include <vector>
+#include <string>
+
+#include "core/XMLPort.h"
+
+namespace orxonox{
+	void setanswers(std::string option1, std::string option2, std::string option3);
+	std::vector <std::string> getanswers(void);
+
+	int getnumOptions();
+	std::vector<std::string> options;
+}
\ No newline at end of file



More information about the Orxonox-commit mailing list