[Orxonox-commit 6958] r11579 - in code/branches/Dialog_HS17: data/gui/layouts data/gui/scripts data/levels src/modules src/modules/dialog
kuchlert at orxonox.net
kuchlert at orxonox.net
Mon Nov 20 16:15:17 CET 2017
Author: kuchlert
Date: 2017-11-20 16:15:17 +0100 (Mon, 20 Nov 2017)
New Revision: 11579
Added:
code/branches/Dialog_HS17/data/gui/layouts/Dialog.layout
code/branches/Dialog_HS17/data/gui/scripts/Dialog.lua
code/branches/Dialog_HS17/data/levels/DialogueShowcase2.oxw
code/branches/Dialog_HS17/src/modules/dialog/
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
Removed:
code/branches/Dialog_HS17/src/modules/dialogue_2/
Modified:
code/branches/Dialog_HS17/src/modules/CMakeLists.txt
Log:
some bug fixed most not
Added: code/branches/Dialog_HS17/data/gui/layouts/Dialog.layout
===================================================================
--- code/branches/Dialog_HS17/data/gui/layouts/Dialog.layout (rev 0)
+++ code/branches/Dialog_HS17/data/gui/layouts/Dialog.layout 2017-11-20 15:15:17 UTC (rev 11579)
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<GUILayout >
+ <Window Type="DefaultWindow" Name="orxonox/Dialogue/Background" >
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
+ <Window Type="MenuWidgets/StaticText" Name="orxonox/Dialogue/Inventory" >
+ <Property Name="Alpha" Value="0.8" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="HorzFormatting" Value="HorzCentred" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="VertFormatting" Value="TopAligned" />
+ <Property Name="UnifiedAreaRect" Value="{{0.15,0},{0.15,0},{0.85,0},{0.8,0}}" />
+ <Window Type="MenuWidgets/StaticText" Name="orxonox/Dialogue/Wrapper" >
+ <Property Name="TextColours" Value="FF4444FF" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="HorzFormatting" Value="HorzCentred" />
+ <Property Name="VertFormatting" Value="TopAligned" />
+ <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.15,0},{0.95,0},{0.92,0}}" />
+ <Window Type="MenuWidgets/TabControl" Name="orxonox/SingleplayerTabControl" >
+ <Property Name="TabHeight" Value="{0,26.4388}" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="TabPanePosition" Value="Top" />
+ <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.1,0},{0,95,0},{0.925,0}}" />
+ </Window>
+ </Window>
+ </Window>
+
+ </Window>
+</GUILayout>
\ No newline at end of file
Added: code/branches/Dialog_HS17/data/gui/scripts/Dialog.lua
===================================================================
--- code/branches/Dialog_HS17/data/gui/scripts/Dialog.lua (rev 0)
+++ code/branches/Dialog_HS17/data/gui/scripts/Dialog.lua 2017-11-20 15:15:17 UTC (rev 11579)
@@ -0,0 +1,112 @@
+
+-- Dialog.lua
+
+local P = createMenuSheet("Dialog")
+
+P.wrapper = nil
+P.answerList = {}
+P.scrollbarWidht = 13
+P.selectedAnswer = {}
+
+P.showing = false
+
+-- Design parameters
+P.imageHeight = 50
+P.detailImageSize = 100
+P.textHeight = 30
+P.buttonWidth = 85
+
+function P.onLoad()
+ P.wrapper = nil
+
+end
+
+function P.onShow()
+ orxonox.CommandExecutor:execute("setTimeFactor 0")
+ P.createDialog()
+ P.showing = true
+
+end
+
+function P.onHide()
+ orxonox.CommandExecutor:execute("setTimeFactor 1")
+ P.showing = false
+ P.cleanup(true)
+end
+
+function P.update()
+ P.updateDialog()
+ if P.showing == false then
+ return
+ end
+
+ P.cleanup(false)
+end
+
+function P.createDialog()
+
+ local dialogManager = orxonox.DialogManager:getInstance()
+
+ root = winMgr:getWindow("orxonox/Dialogue/Inventory")
+ local dialog = dialogManager:getCurrentDialog()
+ root:setText(dialog:getQuestion)
+ 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)
+
+ acceptButton = winMgr:createWindow("MenuWidgets/Button", "/a2Button") --a2 da graphik aus version mit 2 knoepfen uebernommen
+ acceptButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0.1, 0),CEGUI.UDim(0.4, (P.imageHeight-P.textHeight)/2)))
+ acceptButton:setSize(CEGUI.UVector2(CEGUI.UDim(0.8, 0), CEGUI.UDim(0, P.textHeight)))
+ acceptButton:setText("accept")
+ orxonox.GUIManager:subscribeEventHelper(acceptButton, "Clicked", P.name ..".acceptButton_clicked")
+ P.wrapper:addChildWindow(acceptButton)
+
+ P.answerList = {} -- erstellen der tabelle aus AntwortIds und Antworten im Lua
+ local answers = dialog:getAnswers()
+ for ans in answers do
+ P.answerList[ans] = dialog:getAnswer(ans)
+ end
+ --todo herausfinden wie antworten in tabelle enzeigen
+end
+
+
+function P.updateDialog()
+ local dialog = orxonox.DialogManager:getInstance():getDialog()
+ root:setText(dialog:getQuestion)
+ --todo: tabellen updaten
+end
+
+
+function P.cleanup(destroyDetails)
+
+ if P.wrapper ~= nil then
+ winMgr:destroyWindow(P.wrapper)
+ end
+
+ --Destroy details windows.
+ if destroyDetails == false then
+ return
+ end
+ for k,v in pairs(P.detailsWindows) do
+ if v ~= nil then
+ P.destroyDetailWindow(k)
+ end
+ end
+
+end
+
+
+
+function P.acceptButton_clicked(e)
+ local ending = orxonox.DialogManager:getInstance():getDialog:ending()
+
+ if ending then
+ orxonox.CommandExecutor:execute("OrxonoxOverlay toggleVisibility Dialog")
+
+ --herausfindne wie tabelleneintrag uebergeben wird
+ else
+ P.update()
+ end
+end
+
+return P
Added: code/branches/Dialog_HS17/data/levels/DialogueShowcase2.oxw
===================================================================
--- code/branches/Dialog_HS17/data/levels/DialogueShowcase2.oxw (rev 0)
+++ code/branches/Dialog_HS17/data/levels/DialogueShowcase2.oxw 2017-11-20 15:15:17 UTC (rev 11579)
@@ -0,0 +1,77 @@
+<LevelInfo
+ name = "DialogueShowcase2"
+ 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"/>
+
+ <Dialog name="Kurt" currentQuestionId="loop">
+ <Question question="Soll ich dich loopen?" Id="loop">
+ <AnswerId Id="ja"/>
+ <AnswerId Id="nein"/>
+ </Question>
+ <Question question="Dann eben nicht" Id="ok"/>
+ <Answer Id="ja" answer="ja loop mich" nextQuestionId="loop"/>
+ <Answer Id="nein" answer="lieber nicht" nextQuestionId="ok"/>
+ <events>
+ <execute>
+ <EventListener event="test"/>
+ </execute>
+ </events>
+ </Dialog>
+
+ <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/Dialog_HS17/src/modules/CMakeLists.txt
===================================================================
--- code/branches/Dialog_HS17/src/modules/CMakeLists.txt 2017-11-20 15:06:43 UTC (rev 11578)
+++ code/branches/Dialog_HS17/src/modules/CMakeLists.txt 2017-11-20 15:15:17 UTC (rev 11579)
@@ -26,6 +26,7 @@
################ Sub Directories ################
ADD_SUBDIRECTORY(dialogue)
+ADD_SUBDIRECTORY(dialog)
ADD_SUBDIRECTORY(designtools)
ADD_SUBDIRECTORY(gametypes)
ADD_SUBDIRECTORY(notifications)
Added: code/branches/Dialog_HS17/src/modules/dialog/Answer.cc
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/Answer.cc (rev 0)
+++ code/branches/Dialog_HS17/src/modules/dialog/Answer.cc 2017-11-20 15:15:17 UTC (rev 11579)
@@ -0,0 +1,51 @@
+#include "Answer.h"
+
+
+namespace orxonox{
+
+ RegisterClass(Answer);
+
+
+ // Constructor:
+ Answer::Answer(Context* context) : BaseObject(context)
+ {
+ RegisterObject(Answer);
+ }
+
+ void Answer::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(Answer, XMLPort, xmlelement, mode);
+
+ XMLPortParam(Answer, "Id", setAnswerId, getAnswerId, xmlelement, mode);
+ XMLPortParam(Answer, "answer", setAnswer, getAnswer, xmlelement, mode);
+ XMLPortParam(Answer, "nextQuestionId", setNextQuestion, getNextQuestion, xmlelement,mode);
+ }
+
+ void Answer::setAnswerId(std::string answerId){
+ this->answerId_ = answerId;
+ }
+
+ std::string getAnswerId(){
+ return this->answerId_;
+ }
+
+ void Answer::setNextQuestion(std::string nextId)
+ {
+ this->nextQuestionId_ = nextId;
+ }
+
+ std::string Answer::getNextQuestion()
+ {
+ return this->nextQuestionId_;
+ }
+
+ void Answer::setAnswer(std::string answer)
+ {
+ this->answer_ = answer;
+ }
+
+ std::string Answer::getAnswer()
+ {
+ return this->answer_;
+ }
+}
\ No newline at end of file
Added: code/branches/Dialog_HS17/src/modules/dialog/Answer.h
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/Answer.h (rev 0)
+++ code/branches/Dialog_HS17/src/modules/dialog/Answer.h 2017-11-20 15:15:17 UTC (rev 11579)
@@ -0,0 +1,29 @@
+#include "core/BaseObject.h"
+#include "core/XMLPort.h"
+#include <string>
+
+namespace orxonox
+{
+
+ class Answer : public BaseObject
+ {
+ public:
+ Answer(Context* context);
+ virtual ~Answer();
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+ void setAnswerId(std::string answerId);
+ std::string getAnswerId();
+
+ void setNextQuestion(std::string nextId); // "end" um den dialog zu beenden
+ std::string getNextQuestion();
+
+ void setAnswer(std::string awns);
+ std::string getAnswer();
+
+ private:
+ std::string answerId_;
+ std::string answer_;
+ std::string nextQuestionId_;
+ };
+}
Added: code/branches/Dialog_HS17/src/modules/dialog/AnswerId.cc
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/AnswerId.cc (rev 0)
+++ code/branches/Dialog_HS17/src/modules/dialog/AnswerId.cc 2017-11-20 15:15:17 UTC (rev 11579)
@@ -0,0 +1,25 @@
+#include "AnswerId.h"
+
+
+namespace orxonox{
+
+ RegisterClass(AnswerId);
+
+ AnswerId::AnswerId(Context* context) : BaseObject(context)
+ {
+ RegisterObject(AnswerId);
+ }
+ void AnswerId::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(AnswerId, XMLPort, xmlelement, mode);
+
+ XMLPortParam(AnswerId, "Id", setId, getId, xmlelement, mode);
+ }
+
+ void AnswerId::setId(std::string Id){
+ this->Id_ = Id;
+ }
+ const std::string& AnswerId::getId(){
+ return this->Id_;
+ }
+}
\ No newline at end of file
Added: code/branches/Dialog_HS17/src/modules/dialog/AnswerId.h
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/AnswerId.h (rev 0)
+++ code/branches/Dialog_HS17/src/modules/dialog/AnswerId.h 2017-11-20 15:15:17 UTC (rev 11579)
@@ -0,0 +1,22 @@
+#include "core/XMLPort.h"
+#include "core/BaseObject.h"
+
+#include <string>
+
+#pragma once
+
+namespace orxonox{
+ class AnswerId : public BaseObject
+ {
+ public:
+ AnswerId(Context* context);
+ virtual ~AnswerId();
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+ void setId(std::string Id);
+ std::string getId();
+
+ private:
+ std::string Id_;
+ };
+}
\ No newline at end of file
Added: code/branches/Dialog_HS17/src/modules/dialog/CMakeLists.txt
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/CMakeLists.txt (rev 0)
+++ code/branches/Dialog_HS17/src/modules/dialog/CMakeLists.txt 2017-11-20 15:15:17 UTC (rev 11579)
@@ -0,0 +1,18 @@
+SET_SOURCE_FILES(DIALOG_SRC_FILES
+ DialogManager.cc
+ Dialog.cc
+ Question.cc
+ Answer.cc
+ AnswerId.cc
+)
+
+ORXONOX_ADD_LIBRARY(dialog
+ MODULE
+ FIND_HEADER_FILES
+ TOLUA_FILES
+ DialogManager.h
+ Dialog.h
+ LINK_LIBRARIES
+ orxonox
+ SOURCE_FILES ${DIALOG_SRC_FILES}
+)
Added: code/branches/Dialog_HS17/src/modules/dialog/Dialog.cc
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/Dialog.cc (rev 0)
+++ code/branches/Dialog_HS17/src/modules/dialog/Dialog.cc 2017-11-20 15:15:17 UTC (rev 11579)
@@ -0,0 +1,110 @@
+#include "DialogManager.h"
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "core/EventIncludes.h"
+
+namespace orxonox
+{
+
+ RegisterClass(Dialog);
+
+ //Constructor:
+ Dialog::Dialog(Context* context) : BaseObject(context)
+ {
+ RegisterObject(Dialog);
+ }
+
+ void Dialog::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(Dialog, XMLPort, xmlelement, mode);
+
+ XMLPortParam(Dialog, "name", setName, getName, xmlelement, mode);
+ XMLPortParam(Dialog, "currentQuestionId", setCurrentQuestionId, getCurrentQuestionId, xmlelement, mode);
+ XMLPortObject(Dialog, Question, "Questions", addQuestion, getQuestion, xmlelement,mode);
+ XMLPortObject(Dialog, Answer, "Answers", addAnswer, getAnswer, xmlelement, mode);
+ }
+
+ void Dialog::XMLEventPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(Dialog, XMLEventPort, xmlelement, mode);
+
+ XMLPortEventSink(Dialog, BaseObject, "execute", execute, xmlelement, mode);
+ }
+
+ void Dialog::setName(std::string name)
+ {
+ this->name_ = name;
+ }
+
+ std::string Dialog::getName()
+ {
+ return this->name_;
+ }
+
+ void Dialog::setCurrentQuestionId(std::string questionId)
+ {
+ this->currentQuestionId_ = questionId;
+ }
+
+ std::string Dialog::getCurrentQuestionId()
+ {
+ return this->currentQuestionId_;
+ }
+
+
+ void Dialog::addQuestion(Question question) //fuegt Question der Map hinzu
+ {
+ //questions_.emplace(question.getQuestionId, question);
+ }
+
+ void Dialog::addAnswer(Answer answer) //fuegt Answer der Map hinzu
+ {
+ //answers_.emplace(std::make_pair(answer.getAnswerId, answer));
+ }
+
+ std::string Dialog::getQuestion() // returned nichts
+ {
+ Question question = (questions_.find(this->currentQuestionId_))->second;
+ return question.getQuestion();
+ }
+
+ std::string Dialog::getAnswer(std::string answerId) //tolua_export //returned sting der Antwort zur Id.
+ {
+ return (this->answers_.find(answerId))->second.getAnswer();
+ }
+
+ 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();
+ return answers;
+ }
+
+ bool Dialog::execute(bool bTriggered, BaseObject* trigger)
+ {
+ DialogManager& m = DialogManager::getInstance();
+ m.setDialog(this);
+ orxout() << "dialog executed \n";
+ OrxonoxOverlay::showOverlay("Dialog");
+
+ return false;
+ }
+
+ void Dialog::update(std::string givenAnswer)
+ {
+ 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 end = false;
+ if (this->currentQuestionId_ == "end"){
+ end = true;
+ } else if ((questions_.find(this->currentQuestionId_)->second).getAnswerIds().empty()){
+ end = true;
+ }
+ return end;
+ }
+}
\ No newline at end of file
Added: code/branches/Dialog_HS17/src/modules/dialog/Dialog.h
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/Dialog.h (rev 0)
+++ code/branches/Dialog_HS17/src/modules/dialog/Dialog.h 2017-11-20 15:15:17 UTC (rev 11579)
@@ -0,0 +1,45 @@
+#include "core/BaseObject.h"
+#include "Question.h"
+#include "Answer.h"
+#include "core/XMLPort.h"
+#include "overlays/OrxonoxOverlay.h"
+
+#include <string>
+
+namespace orxonox
+{
+ class 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);
+
+ void setName(std::string name);
+ std::string getName();
+
+ void setCurrentQuestionId(std::string questionId);
+ std::string getCurrentQuestionId();
+
+ void addQuestion(Question question); //fuegt Question der Map hinzu
+ void addAnswer(Answer answer); //fuegt Answer der Map hinzu
+
+ std::string getQuestion(); //tolua_export // returned string der momentanen Frage
+ std::string getAnswer(std::string answerId); //tolua_export //returned sting der Antwort zur Id.
+ std::vector<std::string> getAnswers(); //tolua_export // returned vector mit allen momentanen AntwortenIds
+
+ bool execute(bool bTriggered, BaseObject* trigger);
+
+ void update(std::string givenAnswer); //tolua_export
+
+ bool ending(); //tolua_export //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_;
+ };
+}
\ No newline at end of file
Added: code/branches/Dialog_HS17/src/modules/dialog/DialogManager.cc
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/DialogManager.cc (rev 0)
+++ code/branches/Dialog_HS17/src/modules/dialog/DialogManager.cc 2017-11-20 15:15:17 UTC (rev 11579)
@@ -0,0 +1,65 @@
+/*#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;
+ }
+ }
+} */
+
+#include "DialogManager.h"
+#include "core/CoreIncludes.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
+
+namespace orxonox
+{
+ ManageScopedSingleton(DialogManager, ScopeID::ROOT, false);
+
+ RegisterAbstractClass(DialogManager).inheritsFrom<Listable>();
+
+ DialogManager::DialogManager()
+ {
+ RegisterObject(DialogManager);
+
+ this->value_ = 999;
+ }
+}
Added: code/branches/Dialog_HS17/src/modules/dialog/DialogManager.h
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/DialogManager.h (rev 0)
+++ code/branches/Dialog_HS17/src/modules/dialog/DialogManager.h 2017-11-20 15:15:17 UTC (rev 11579)
@@ -0,0 +1,86 @@
+/*
+#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 "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
+ {
+ friend class Singleton<DialogManager>;
+
+ public:
+ DialogManager();
+
+ int getValue() const
+ { return this->value_; }
+
+ static DialogManager& getInstance() { return Singleton<DialogManager>::getInstance(); }
+
+ void setDialog(Dialog* dialog);
+ const Dialog& getCurrentDialog();
+ bool empty();
+
+ private:
+ Dialog* currentTalk_;
+ int value_;
+
+ static DialogManager* singletonPtr_s;
+ };
+}
+
+#endif /* _DialogManager_H__ */
\ No newline at end of file
Added: code/branches/Dialog_HS17/src/modules/dialog/Question.cc
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/Question.cc (rev 0)
+++ code/branches/Dialog_HS17/src/modules/dialog/Question.cc 2017-11-20 15:15:17 UTC (rev 11579)
@@ -0,0 +1,55 @@
+#include "Question.h"
+
+
+namespace orxonox
+{
+
+ RegisterClass(Question);
+
+ Question::Question(Context* context) : BaseObject(context)
+ {
+ RegisterObject(Question);
+ }
+
+ void Question::XMLPort(Element& xmlement, XMLPort::Mode mode)
+ {
+ SUPER(Question, XMLPort, xmlement, mode);
+
+ XMLPortParam(Question, "question", setQuestion, getQuestion, xmlement, mode);
+ XMLPortParam(Question, "Id", setQuestionId, getQuestionId, xmlement, mode);
+
+ XMLPortObject(Question, AnswerId, "answers", addAnswerId, getAnswerIds, xmlement, mode);
+ }
+
+ void Question::setQuestionId(std::string Id)
+ {
+ this->questionId_ = Id;
+ }
+
+ std::string Question::getQuestionId()
+ {
+ return this->questionId_;
+ }
+
+ void Question::setQuestion(std::string question)
+ {
+ this->question_ = question;
+ }
+
+ cstd::string Question::getQuestion()
+ {
+ return this->question_;
+ }
+
+ void Question::addAnswerId(AnswerId answerId)
+ {
+ this->answerIds_.push_back(answerId.getId);
+ }
+
+
+ std::vector<std::string> Question::getAnswerIds()
+ {
+ return this->answerIds_;
+ }
+
+}
\ No newline at end of file
Added: code/branches/Dialog_HS17/src/modules/dialog/Question.h
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/Question.h (rev 0)
+++ code/branches/Dialog_HS17/src/modules/dialog/Question.h 2017-11-20 15:15:17 UTC (rev 11579)
@@ -0,0 +1,37 @@
+#include "core/BaseObject.h"
+#include "AnswerId.h"
+#include "core/XMLPort.h"
+
+#include <string>
+
+namespace orxonox
+{
+ class Question : public BaseObject
+ {
+ public:
+ Question(Context* context);
+ virtual ~Question();
+ virtual void XMLPort(Element& xmelement, XMLPort::Mode mode);
+
+ void setQuestionId(std::string Id);
+ std::string getQuestionId();
+
+ void setQuestion(std::string question);
+ std::string getQuestion();
+
+ void addAnswerId(AnswerId answerId); //leer lassen um Dialog zu beenden
+
+
+ //braucht es getAnswerId oder reicht es andere funktion anzugeben,
+ // die sowieso gebraucht wird?
+
+ std::vector<std::string> getAnswerIds(); //returnt vektor mit allen Ids
+
+
+
+ private:
+ std::string questionId_;
+ std::string question_;
+ std::vector<std::string> answerIds_;
+ };
+}
\ No newline at end of file
More information about the Orxonox-commit
mailing list