[Orxonox-commit 6990] r11611 - code/branches/Dialog_HS17/src/modules/dialog

kuchlert at orxonox.net kuchlert at orxonox.net
Thu Nov 30 09:33:27 CET 2017


Author: kuchlert
Date: 2017-11-30 09:33:27 +0100 (Thu, 30 Nov 2017)
New Revision: 11611

Added:
   code/branches/Dialog_HS17/src/modules/dialog/DialogPrereqs.h
Modified:
   code/branches/Dialog_HS17/src/modules/dialog/Answer.cc
   code/branches/Dialog_HS17/src/modules/dialog/Answer.h
   code/branches/Dialog_HS17/src/modules/dialog/AnswerId.cc
   code/branches/Dialog_HS17/src/modules/dialog/AnswerId.h
   code/branches/Dialog_HS17/src/modules/dialog/CMakeLists.txt
   code/branches/Dialog_HS17/src/modules/dialog/Dialog.cc
   code/branches/Dialog_HS17/src/modules/dialog/Dialog.h
   code/branches/Dialog_HS17/src/modules/dialog/DialogManager.cc
   code/branches/Dialog_HS17/src/modules/dialog/DialogManager.h
   code/branches/Dialog_HS17/src/modules/dialog/Question.cc
   code/branches/Dialog_HS17/src/modules/dialog/Question.h
Log:
fixed addQuestion and addAnswer in Dialog

Modified: code/branches/Dialog_HS17/src/modules/dialog/Answer.cc
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/Answer.cc	2017-11-27 17:54:29 UTC (rev 11610)
+++ code/branches/Dialog_HS17/src/modules/dialog/Answer.cc	2017-11-30 08:33:27 UTC (rev 11611)
@@ -1,4 +1,5 @@
 #include "Answer.h"
+#include "core/CoreIncludes.h"
 
 
 namespace orxonox{

Modified: code/branches/Dialog_HS17/src/modules/dialog/Answer.h
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/Answer.h	2017-11-27 17:54:29 UTC (rev 11610)
+++ code/branches/Dialog_HS17/src/modules/dialog/Answer.h	2017-11-30 08:33:27 UTC (rev 11611)
@@ -2,6 +2,7 @@
 #define _Answer_H__
 
 #include "core/BaseObject.h"
+#include "DialogPrereqs.h"
 #include "core/XMLPort.h"
 #include "core/CoreIncludes.h"
 #include <string>
@@ -9,11 +10,11 @@
 namespace orxonox
 {
 	
-	class Answer : public BaseObject
+	class _DialogExport Answer : public BaseObject
 	{
 		public:
 			Answer(Context* context);
-		// 	virtual ~Answer();
+			
 			virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
 
 			void setAnswerId(std::string answerId); 

Modified: code/branches/Dialog_HS17/src/modules/dialog/AnswerId.cc
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/AnswerId.cc	2017-11-27 17:54:29 UTC (rev 11610)
+++ code/branches/Dialog_HS17/src/modules/dialog/AnswerId.cc	2017-11-30 08:33:27 UTC (rev 11611)
@@ -1,4 +1,5 @@
 #include "AnswerId.h"
+#include "core/CoreIncludes.h"
 
 
 namespace orxonox{
@@ -9,6 +10,7 @@
 	{
 		RegisterObject(AnswerId);
 	}
+
 	void AnswerId::XMLPort(Element& xmlelement, XMLPort::Mode mode)
 	{
 		SUPER(AnswerId, XMLPort, xmlelement, mode);
@@ -16,10 +18,13 @@
 		XMLPortParam(AnswerId, "Id", setId, getId, xmlelement, mode);
 	}
 
-	void AnswerId::setId(std::string Id){
-		this->Id_ = Id;
+	void AnswerId::setId(std::string id)
+	{
+		this->id_ = id;
 	}
-	std::string AnswerId::getId(){
-		return this->Id_;
+	
+	std::string AnswerId::getId()
+	{
+		return this->id_;
 	}
 }
\ No newline at end of file

Modified: code/branches/Dialog_HS17/src/modules/dialog/AnswerId.h
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/AnswerId.h	2017-11-27 17:54:29 UTC (rev 11610)
+++ code/branches/Dialog_HS17/src/modules/dialog/AnswerId.h	2017-11-30 08:33:27 UTC (rev 11611)
@@ -12,14 +12,14 @@
 	{
 		public:
 			AnswerId(Context* context);
-		// 	virtual ~AnswerId();
+			
 			virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
 
-			void setId(std::string Id);
-			std::string getId();
+            void setId(std::string Id);
+            std::string getId();
 
 		private: 
-			std::string Id_;
+			std::string id_;
 	};
 }
 

Modified: code/branches/Dialog_HS17/src/modules/dialog/CMakeLists.txt
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/CMakeLists.txt	2017-11-27 17:54:29 UTC (rev 11610)
+++ code/branches/Dialog_HS17/src/modules/dialog/CMakeLists.txt	2017-11-30 08:33:27 UTC (rev 11611)
@@ -10,6 +10,7 @@
   MODULE
   FIND_HEADER_FILES
    TOLUA_FILES
+   DialogManager.h
   LINK_LIBRARIES
     orxonox
   SOURCE_FILES ${DIALOG_SRC_FILES}

Modified: code/branches/Dialog_HS17/src/modules/dialog/Dialog.cc
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/Dialog.cc	2017-11-27 17:54:29 UTC (rev 11610)
+++ code/branches/Dialog_HS17/src/modules/dialog/Dialog.cc	2017-11-30 08:33:27 UTC (rev 11611)
@@ -5,6 +5,7 @@
 #include "Dialog.h"
 #include "Question.h"
 
+
 namespace orxonox
 {
 
@@ -56,12 +57,12 @@
 
 	void Dialog::addQuestion(Question* question) //fuegt Question der Map hinzu
 	{
-		//questions_.emplace(question->getQuestionId(), question->getQuestion());
+		this->questions_.insert(make_pair(question->getQuestionId(), question));
 	}
 
 	void Dialog::addAnswer(Answer* answer) //fuegt Answer der Map hinzu
 	{
-		//answers_.emplace(std::make_pair(answer->getAnswerId(), answer->getAnswer()));
+		this->answers_.insert(make_pair(answer->getAnswerId(), answer));
 	}
 
 	Question* Dialog::getQuestion(unsigned int index) const // returned nichts
@@ -71,7 +72,7 @@
 		// return question.getQuestion();
 	}
 
-	Answer* Dialog::getAnswer(unsigned int index) const//tolua_export		//returned sting der Antwort zur Id.
+	Answer* Dialog::getAnswer(unsigned int index) const	//returned sting der Antwort zur Id.
 	{
 		return nullptr;
 		// return (this->answers_.find(answerId))->second.getAnswer();
@@ -80,8 +81,8 @@
 	std::vector<std::string> Dialog::getAnswers() // returned vector mit allen momentanen AntwortenIds
 	{
 
-		Question question = (questions_.find(this->currentQuestionId_))->second;
-		std::vector<std::string> answers = question.getAnswerIds();
+		Question* question = (this->questions_.find(this->currentQuestionId_))->second;
+		std::vector<std::string> answers = question->getAnswerIds();
 		return answers;
 	} 
 	
@@ -97,16 +98,16 @@
 
     void Dialog::update(std::string givenAnswer)
     {
-    	Answer answer = (answers_.find(givenAnswer))->second;
-    	this->currentQuestionId_ = answer.getNextQuestion();
+    	Answer* answer = (answers_.find(givenAnswer))->second;
+    	this->currentQuestionId_ = answer->getNextQuestion();
     }
 
-    bool Dialog::ending() //tolua_export	//retruned true wenn die Id der Antwort end ist oder keine Antworten auf die frage eingetragen sind
+    bool Dialog::ending() //retruned true wenn die Id der Antwort end ist oder keine Antworten auf die frage eingetragen sind
     {
     	bool end = false;
     	if (this->currentQuestionId_ == "end"){
     		end = true;
-    	} else if ((questions_.find(this->currentQuestionId_)->second).getAnswerIds().empty()){
+    	} else if ((this->questions_.find(this->currentQuestionId_)->second)->getAnswerIds().empty()){
     		end = true;
     	}	
     	return end;

Modified: code/branches/Dialog_HS17/src/modules/dialog/Dialog.h
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/Dialog.h	2017-11-27 17:54:29 UTC (rev 11610)
+++ code/branches/Dialog_HS17/src/modules/dialog/Dialog.h	2017-11-30 08:33:27 UTC (rev 11611)
@@ -2,6 +2,7 @@
 #define _Dialog_H__
 
 #include "core/BaseObject.h"
+#include "DialogPrereqs.h"
 #include "Question.h"
 #include "Answer.h"
 #include "core/XMLPort.h"
@@ -8,15 +9,17 @@
 #include "core/CoreIncludes.h"
 #include "overlays/OrxonoxOverlay.h"
 
+#include <map>
+#include <vector>
 #include <string>
 
 namespace orxonox
 {
-	class Dialog : public BaseObject
+	class _DialogExport Dialog : public BaseObject
 	{
 		public:
 			Dialog(Context* context);
-			// virtual ~Dialog();
+
 			virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
 			virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
 
@@ -29,22 +32,22 @@
 			void addQuestion(Question* question); //fuegt Question der Map hinzu
 			void addAnswer(Answer* answer); //fuegt Answer der Map hinzu
 
-			Question* getQuestion(unsigned int index) const; //tolua_export	// returned string der momentanen Frage
-			Answer* getAnswer(unsigned int index) const; //tolua_export	// returned string der momentanen Frage
-			std::vector<std::string> getAnswers(); //tolua_export	// returned vector mit allen momentanen AntwortenIds
+			Question* getQuestion(unsigned int index) const; // returned string der momentanen Frage
+			Answer* getAnswer(unsigned int index) const; // returned string der momentanen Frage
+			std::vector<std::string> getAnswers(); 	// returned vector mit allen momentanen AntwortenIds
 
 	 		bool execute(bool bTriggered, BaseObject* trigger);
 
-			void update(std::string givenAnswer);	//tolua_export
+			void update(std::string givenAnswer);
 
-			bool ending(); //tolua_export	//retruned true wenn die Id der Antwort end ist oder keine Antworten auf die frage eingetragen sind
+			bool ending(); //retruned true wenn die Id der Antwort end ist oder keine Antworten auf die frage eingetragen sind
 
 
 		private: 
 			std::string name_;
 			std::string currentQuestionId_;
-			std::map<std::string, Question> questions_;
-			std::map<std::string, Answer> answers_;
+			std::map<std::string, Question*> questions_;
+			std::map<std::string, Answer*> answers_;
 	};
 }
 

Modified: code/branches/Dialog_HS17/src/modules/dialog/DialogManager.cc
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/DialogManager.cc	2017-11-27 17:54:29 UTC (rev 11610)
+++ code/branches/Dialog_HS17/src/modules/dialog/DialogManager.cc	2017-11-30 08:33:27 UTC (rev 11611)
@@ -37,50 +37,3 @@
 		}
 	} 
 }
-/*#include "core/CoreIncludes.h"
-#include "core/LuaState.h"
-#include "core/GUIManager.h"
-#include "core/class/Identifier.h"
-#include "core/singleton/ScopedSingletonIncludes.h"
-#include "network/Host.h"
-#include "network/NetworkFunctionIncludes.h"
-#include "DialogManager.h"
-#include <vector>
-#include <string>
-#include "core/XMLPort.h"
-#include "Dialog.h"
-
-
-
-namespace orxonox {
-
-	ManageScopedSingleton(DialogManager, ScopeID::ROOT, false);
-
-
-	DialogManager::DialogManager()
-	{
-		this->currentTalk_ = NULL;
-	}
-
-	void DialogManager::setDialog(Dialog* dialog)
-	{
-		this->currentTalk_ = dialog;	
-	}
-
-	const Dialog& getCurrentDialog()
-	{
-		return this->currentTalk_;
-	}
-	
-	bool DialogManager::empty()
-	{
-		if(this->currentTalk_ == NULL)
-		{
-			return true;
-		}
-		else 
-		{
-			return false;
-		}
-	} 
-} */
\ No newline at end of file

Modified: code/branches/Dialog_HS17/src/modules/dialog/DialogManager.h
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/DialogManager.h	2017-11-27 17:54:29 UTC (rev 11610)
+++ code/branches/Dialog_HS17/src/modules/dialog/DialogManager.h	2017-11-30 08:33:27 UTC (rev 11611)
@@ -1,65 +1,14 @@
-/*
 #ifndef _DialogManager_H__
 #define _DialogManager_H__
 
-#include "core/CoreIncludes.h"
-#include "core/LuaState.h"
-#include "core/GUIManager.h"
-#include "core/class/Identifier.h"
-#include "core/singleton/ScopedSingletonIncludes.h"
-#include "network/Host.h"
-#include "network/NetworkFunctionIncludes.h"
+#include "DialogPrereqs.h"
 #include "util/Singleton.h"
-#include <string>
-#include <vector>
-#include "core/config/Configurable.h"
-#include "core/XMLPort.h"
-#include "core/EventIncludes.h"
-#include "Dialog.h"
-
-
-
-
-
-namespace orxonox //tolua_export
-
-{//tolua_export
-	class _OrxonoxExport DialogManager //tolua_export
-	: public Singleton<DialogManager>
-	{//tolua_export
-		friend class Singleton<DialogManager>;
-	
-		public:
-		
-		DialogManager();
-		
-
-		static DialogManager& getInstance() { return Singleton<DialogManager>::getInstance(); } //tolua_export
-		
-
-		void setDialog(Dialog* dialog); //tolua_export	// the triggered dialog sets it self so the lua can get to it.
-		const Dialog& getCurrentDialog(); 	//tolua_export
-		bool empty(); //tolua_export //returns true if no dialog is set.
-
-private:
-	Dialog* currentTalk_; //Dialog which is currently set.
-	static DialogManager* singletonPtr_s;
-
-	};//tolua_export
-}//tolua_export
-#endif
- */
-
-#ifndef _DialogManager_H__
-#define _DialogManager_H__
-
-#include "util/Singleton.h"
 #include "core/object/Listable.h"
 #include "Dialog.h"
 
 namespace orxonox
 {
-    class DialogManager : public Singleton<DialogManager>, public Listable
+    class _DialogExport DialogManager : public Singleton<DialogManager>, public Listable
     {
         friend class Singleton<DialogManager>;
 
@@ -66,18 +15,20 @@
         public:
             DialogManager();
 
-            int getValue() const
-                { return this->value_; }
+           // int getValue() const { return this->value_; }
 
-        	static DialogManager& getInstance() { return Singleton<DialogManager>::getInstance(); }
+        	static DialogManager& getInstance() { return Singleton<DialogManager>::getInstance(); } //toloa_export
 
        	 	void setDialog(Dialog* dialog);
         	const Dialog* getCurrentDialog();
        		bool empty();
 
+            //form here on all lua functionality used in lua scrips is declared
+
+
         private:
         	Dialog* currentTalk_;
-            int value_;
+            //int value_;
 
             static DialogManager* singletonPtr_s;
     };

Added: code/branches/Dialog_HS17/src/modules/dialog/DialogPrereqs.h
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/DialogPrereqs.h	                        (rev 0)
+++ code/branches/Dialog_HS17/src/modules/dialog/DialogPrereqs.h	2017-11-30 08:33:27 UTC (rev 11611)
@@ -0,0 +1,79 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Damian 'Mozork' Frick
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+ at file
+ at brief
+    Shared library macros, enums, constants and forward declarations for the questsystem module
+*/
+
+#ifndef _DialogPrereqs_H__
+#define _DialogPrereqs_H__
+
+#include "OrxonoxConfig.h"
+#include "OrxonoxPrereqs.h"
+
+//-----------------------------------------------------------------------
+// Shared library settings
+//-----------------------------------------------------------------------
+
+#if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(Dialogue_STATIC_BUILD)
+#  ifdef Dialogue_SHARED_BUILD
+#    define _DialogExport __declspec(dllexport)
+#  else
+#    if defined( __MINGW32__ )
+#      define _DialogExport
+#    else
+#      define _DialogExport __declspec(dllimport)
+#    endif
+#  endif
+#  define _DialogPrivate
+#elif defined (ORXONOX_GCC_VISIBILITY)
+#  define _DialogExport  __attribute__ ((visibility("default")))
+#  define _DialogPrivate __attribute__ ((visibility("hidden")))
+#else
+#  define _DialogExport
+#  define _DialogPrivate
+#endif
+
+//-----------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------
+
+namespace orxonox
+{
+
+    class DialogManager;
+    class Dialog;
+    class Answer;
+    class Question;
+    class AnswerId;
+   
+}
+
+#endif /* _DialogPrereqs_H__ */

Modified: code/branches/Dialog_HS17/src/modules/dialog/Question.cc
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/Question.cc	2017-11-27 17:54:29 UTC (rev 11610)
+++ code/branches/Dialog_HS17/src/modules/dialog/Question.cc	2017-11-30 08:33:27 UTC (rev 11611)
@@ -1,6 +1,6 @@
 #include "Question.h"
+#include "core/CoreIncludes.h"
 
-
 namespace orxonox
 {
 

Modified: code/branches/Dialog_HS17/src/modules/dialog/Question.h
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/Question.h	2017-11-27 17:54:29 UTC (rev 11610)
+++ code/branches/Dialog_HS17/src/modules/dialog/Question.h	2017-11-30 08:33:27 UTC (rev 11611)
@@ -2,19 +2,21 @@
 #define _Question_H__
 
 #include "core/BaseObject.h"
+#include "DialogPrereqs.h"
 #include "AnswerId.h"
 #include "core/XMLPort.h"
 #include "core/CoreIncludes.h"
 
+
 #include <string>
 
 namespace orxonox
 {
-	class Question : public BaseObject
+	class _DialogExport Question : public BaseObject
 	{
 		public:
 			Question(Context* context);
-		// 	virtual ~Question();
+
 			virtual void XMLPort(Element& xmelement, XMLPort::Mode mode);
 
 			void setQuestionId(std::string Id);



More information about the Orxonox-commit mailing list