[Orxonox-commit 7025] r11644 - in code/branches/Dialog_HS17: data/gui/layouts data/gui/scripts data/levels src/modules/dialog
kuchlert at orxonox.net
kuchlert at orxonox.net
Fri Dec 8 14:55:16 CET 2017
Author: kuchlert
Date: 2017-12-08 14:55:15 +0100 (Fri, 08 Dec 2017)
New Revision: 11644
Modified:
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/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/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:
eigentlich fertig nur noch altes system entfernen
Modified: code/branches/Dialog_HS17/data/gui/layouts/Dialog.layout
===================================================================
--- code/branches/Dialog_HS17/data/gui/layouts/Dialog.layout 2017-12-07 17:25:56 UTC (rev 11643)
+++ code/branches/Dialog_HS17/data/gui/layouts/Dialog.layout 2017-12-08 13:55:15 UTC (rev 11644)
@@ -30,18 +30,12 @@
<Property Name="UnifiedAreaRect" Value="{{0.3,0},{0.05,0},{0.95,0},{0.15,0}}" />
</Window>
- <Window Type="MenuWidgets/StaticText" Name="orxonox/DialogAns" >
- <Property Name="InheritsAlpha" Value="False" />
- <Property Name="HorzFormatting" Value="HorzCentred" />
+ <Window Type="MenuWidgets/Listbox" Name="orxonox/AnsListbox" >
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
- <Property Name="VertFormatting" Value="TopAligned" />
- <Property Name="UnifiedAreaRect" Value="{{0.604166,0},{0.15,0},{0.958333,0},{0.636,0}}" />
- <Window Type="MenuWidgets/Listbox" Name="orxonox/AnsListbox" >
- <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
- <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.225,0},{0.95,0},{0.92,0}}" />
- <Event Name="ItemSelectionChanged" Function="Dialog.answer_changed" />
- </Window>
+ <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.225,0},{0.95,0},{0.85,0}}" />
+ <Event Name="ItemSelectionChanged" Function="Dialog.answer_changed" />
</Window>
+
<Window Type="MenuWidgets/Button" Name="orxonox/SayButton" >
<Property Name="Text" Value="Say" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
Modified: code/branches/Dialog_HS17/data/gui/scripts/Dialog.lua
===================================================================
--- code/branches/Dialog_HS17/data/gui/scripts/Dialog.lua 2017-12-07 17:25:56 UTC (rev 11643)
+++ code/branches/Dialog_HS17/data/gui/scripts/Dialog.lua 2017-12-08 13:55:15 UTC (rev 11644)
@@ -5,18 +5,13 @@
P.wrapper = nil
P.detailsWindows = {}
P.showing = false
+P.choice = 0
--- Design parameters
-P.imageHeight = 50
-P.detailImageSize = 100
-P.textHeight = 50
-P.buttonWidth = 50
-
-function P.onLoad()
+function P.onLoad() --wird ausgefuert wenn Fenster geladen
P.wrapper = nil
end
-function P.onShow()
+function P.onShow() --wird ausgefuert wenn Dialogfenster gezeigt
orxonox.CommandExecutor:execute("setTimeFactor 0")
P.createDialog()
@@ -24,13 +19,13 @@
end
-function P.onHide()
+function P.onHide() --aufgefuert wenn Fenster geschlossen wird
orxonox.CommandExecutor:execute("setTimeFactor 1")
P.showing = false
P.cleanup(true)
end
-function P.createDialog()
+function P.createDialog() -- initiallisiert das Dialog Fenster, setzt Namen sowie die erste Frage mit enstprechenden Antworten
local manager = orxonox.DialogManager:getInstance()
@@ -43,23 +38,17 @@
local question = manager:getQuestion()
questionfiled:setText(question)
- listboxwindow = winMgr:getWindow("orxonox/AnsListbox")
+ local listboxwindow = winMgr:getWindow("orxonox/AnsListbox")
+ CEGUI.toListbox(listboxwindow):resetList()
- local themeList = {}
- --[[
- table.insert(themeList, "Default")
- table.insert(themeList, "Drum n' Bass")
- table.insert(themeList, "8-Bit Style")
- table.insert(themeList, "Corny Jazz")
- table.insert(themeList, "Metal")
- --]]
+ local ansList = {}
local anssize = manager:getSize()
for index = 0, anssize -1, 1 do
- table.insert(themeList, manager:getAnswer(index))
+ table.insert(ansList, manager:getAnswer(index))
end
- for k,v in pairs(themeList) do
+ for k,v in pairs(ansList) do
item = CEGUI.createListboxTextItem(v)
item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
CEGUI.toListbox(listboxwindow):addItem(item)
@@ -66,22 +55,46 @@
end
end
-function P.updateDialog()
+function P.updateDialog() --updated den Dialog entsprechend der Ausgeaehlten option der letzten Frage, setzt Frage und Antwortmoeglichkeiten neu
local manager = orxonox.DialogManager:getInstance()
- --manager:update()
+ manager:update(P.choice)
local questionfiled = winMgr:getWindow("orxonox/Dialog/Question")
local question = manager:getQuestion()
questionfiled:setText(question)
+
+ local listboxwindow = winMgr:getWindow("orxonox/AnsListbox")
+ listboxwindow:resetList()
+
+ local ansList = {}
+ local anssize = manager:getSize()
+
+ for index = 0, anssize -1, 1 do
+ table.insert(ansList, manager:getAnswer(index))
+ end
+
+ for k,v in pairs(ansList) do
+ item = CEGUI.createListboxTextItem(v)
+ item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
+ CEGUI.toListbox(listboxwindow):addItem(item)
+ end
+
+ P.choice = 0
end
-function P.answer_changed(e)
- -- body
+function P.answer_changed(e) --wird aufgerufen falls Auswahl geaendert wird und setzt enstprechenden Indexparameter
+ listboxwindow = winMgr:getWindow("orxonox/AnsListbox")
+ selection = listboxwindow:getFirstSelectedItem()
+ if selection ~= nil then
+ P.choice = listboxwindow:getItemIndex(selection)
+ else
+ P.choice = 0
+ end
end
-function P.cleanup(destroyDetails)
-
+function P.cleanup(destroyDetails) --loest Fenster wieder auf (!nicht selbst geschrieben, nur uebernommen, eventuell nicht noetiger code)
+
if P.wrapper ~= nil then
winMgr:destroyWindow(P.wrapper)
end
@@ -100,14 +113,11 @@
-function P.Button_clicked(e)
- local ending = orxonox.DialogManager:getInstance():endtest()
- orxonox.CommandExecutor:execute("OrxonoxOverlay toggleVisibility Dialog")
+function P.Button_clicked(e) --wird bei click auf say knopf ausgeloest, entscheidet ob Dialog schliesst oder updated und fuert entsprechen aus
+ local ending = orxonox.DialogManager:getInstance():endtest(P.choice)
if ending then
orxonox.CommandExecutor:execute("OrxonoxOverlay toggleVisibility Dialog")
-
-
else
P.updateDialog(index)
end
Modified: code/branches/Dialog_HS17/data/levels/DialogueShowcase2.oxw
===================================================================
--- code/branches/Dialog_HS17/data/levels/DialogueShowcase2.oxw 2017-12-07 17:25:56 UTC (rev 11643)
+++ code/branches/Dialog_HS17/data/levels/DialogueShowcase2.oxw 2017-12-08 13:55:15 UTC (rev 11644)
@@ -1,5 +1,5 @@
<LevelInfo
- name = "DialogueShowcase2"
+ name = "DialogShowase"
description = "A level to show and test the functionality of the Dialogue module."
tags = "test"
screenshot = "emptylevel.png"
@@ -31,19 +31,34 @@
<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">
+ <Dialog name="Kurt" currentQuestionId="loop1">
<questions>
- <Question question="Soll ich dich loopen?" Id="loop">
+ <Question question="Soll ich dich einmal loopen?" Id="loop1">
<answerIds>
<AnswerId Id="ja"/>
<AnswerId Id="nein"/>
+ <AnswerId Id="giveItToMe"/>
</answerIds>
</Question>
+ <Question question="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua." Id="lorem">
+ <answerIds>
+ <AnswerId Id="end"/>
+ </answerIds>
+ </Question>
+ <Question question="Soll ich dich nochmal loopen?" Id="loop2">
+ <answerIds>
+ <AnswerId Id="ja"/>
+ <AnswerId Id="nein"/>
+ <AnswerId Id="end"/>
+ </answerIds>
+ </Question>
<Question question="Dann eben nicht" Id="ok"/>
</questions>
<answers>
- <Answer Id="ja" answer="ja loop mich" nextQuestionId="loop"/>
+ <Answer Id="giveItToMe" answer="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." nextQuestionId="lorem"/>
+ <Answer Id="ja" answer="ja loop mich" nextQuestionId="loop2"/>
<Answer Id="nein" answer="lieber nicht" nextQuestionId="ok"/>
+ <Answer Id="end" answer="ich geh dann mal" nextQuestionId=""/>
</answers>
<events>
<execute>
@@ -51,29 +66,7 @@
</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 />
Modified: code/branches/Dialog_HS17/src/modules/dialog/Answer.cc
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/Answer.cc 2017-12-07 17:25:56 UTC (rev 11643)
+++ code/branches/Dialog_HS17/src/modules/dialog/Answer.cc 2017-12-08 13:55:15 UTC (rev 11644)
@@ -22,30 +22,31 @@
XMLPortParam(Answer, "nextQuestionId", setNextQuestion, getNextQuestion, xmlelement,mode);
}
- void Answer::setAnswerId(std::string answerId){
+ void Answer::setAnswerId(const std::string& answerId){
this->answerId_ = answerId;
}
- std::string Answer::getAnswerId(){
+ const std::string& Answer::getAnswerId() const
+ {
return this->answerId_;
}
- void Answer::setNextQuestion(std::string nextId)
+ void Answer::setNextQuestion(const std::string& nextId)
{
this->nextQuestionId_ = nextId;
}
- std::string Answer::getNextQuestion()
+ const std::string& Answer::getNextQuestion() const
{
return this->nextQuestionId_;
}
- void Answer::setAnswer(std::string answer)
+ void Answer::setAnswer(const std::string& answer)
{
this->answer_ = answer;
}
- std::string Answer::getAnswer()
+ const std::string& Answer::getAnswer() const
{
return this->answer_;
}
Modified: code/branches/Dialog_HS17/src/modules/dialog/Answer.h
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/Answer.h 2017-12-07 17:25:56 UTC (rev 11643)
+++ code/branches/Dialog_HS17/src/modules/dialog/Answer.h 2017-12-08 13:55:15 UTC (rev 11644)
@@ -17,14 +17,14 @@
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
- void setAnswerId(std::string answerId);
- std::string getAnswerId();
+ void setAnswerId(const std::string& answerId); //xmlPort-Funktion, setzt AntwortId
+ const std::string& getAnswerId() const; //xmlPort-Funktion, gibt AntwortId
- void setNextQuestion(std::string nextId); // "end" um den dialog zu beenden
- std::string getNextQuestion();
+ void setNextQuestion(const std::string& nextId); //xmlPort-Funktion, um Dialog zu beenden tag benutzen der von keiner Frage benutzt wird
+ const std::string& getNextQuestion() const; //xmlPort-Funktion, gibt Id der Folgefrage
- void setAnswer(std::string awns);
- std::string getAnswer();
+ void setAnswer(const std::string& awns); //xmlPort-Funktion, setzt Antworttext
+ const std::string& getAnswer() const; //xmlPort-Funktion, gibt Antworttext
private:
std::string answerId_;
Modified: code/branches/Dialog_HS17/src/modules/dialog/AnswerId.cc
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/AnswerId.cc 2017-12-07 17:25:56 UTC (rev 11643)
+++ code/branches/Dialog_HS17/src/modules/dialog/AnswerId.cc 2017-12-08 13:55:15 UTC (rev 11644)
@@ -18,12 +18,12 @@
XMLPortParam(AnswerId, "Id", setId, getId, xmlelement, mode);
}
- void AnswerId::setId(std::string id)
+ void AnswerId::setId(const std::string& id)
{
this->id_ = id;
}
- std::string AnswerId::getId()
+ const std::string& AnswerId::getId() const
{
return this->id_;
}
Modified: code/branches/Dialog_HS17/src/modules/dialog/AnswerId.h
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/AnswerId.h 2017-12-07 17:25:56 UTC (rev 11643)
+++ code/branches/Dialog_HS17/src/modules/dialog/AnswerId.h 2017-12-08 13:55:15 UTC (rev 11644)
@@ -15,8 +15,8 @@
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
- void setId(std::string Id);
- std::string getId();
+ void setId(const std::string& Id); //allows to set Id, only use in xmlPort for initializing AnswerIds in lvl files
+ const std::string& getId() const; //allows to get Id, used in xmlPort
private:
std::string id_;
Modified: code/branches/Dialog_HS17/src/modules/dialog/Dialog.cc
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/Dialog.cc 2017-12-07 17:25:56 UTC (rev 11643)
+++ code/branches/Dialog_HS17/src/modules/dialog/Dialog.cc 2017-12-08 13:55:15 UTC (rev 11644)
@@ -34,22 +34,22 @@
XMLPortEventSink(Dialog, BaseObject, "execute", execute, xmlelement, mode);
}
- void Dialog::setName(std::string name)
+ void Dialog::setName(const std::string& name)
{
this->name_ = name;
}
- std::string Dialog::getName()
+ const std::string& Dialog::getName() const
{
return this->name_;
}
- void Dialog::setCurrentQuestionId(std::string questionId)
+ void Dialog::setCurrentQuestionId(const std::string& questionId)
{
this->currentQuestionId_ = questionId;
}
- std::string Dialog::getCurrentQuestionId()
+ const std::string& Dialog::getCurrentQuestionId() const
{
return this->currentQuestionId_;
}
@@ -60,29 +60,27 @@
this->questions_.insert(make_pair(question->getQuestionId(), question));
}
- void Dialog::addAnswer(Answer* answer) //fuegt Answer der Map hinzu
+ const Question* Dialog::getQuestion() const // returned nichts
{
- this->answers_.insert(make_pair(answer->getAnswerId(), answer));
+ return nullptr;
}
- Question* Dialog::getQuestion(unsigned int index) const // returned nichts
+ void Dialog::addAnswer(Answer* answer) //fuegt Answer der Map hinzu
{
- return nullptr;
- // Question question = (questions_.find(this->currentQuestionId_))->second;
- // return question.getQuestion();
+ this->answers_.insert(make_pair(answer->getAnswerId(), answer));
}
- Answer* Dialog::getAnswer(unsigned int index) const //returned sting der Antwort zur Id.
+ const Answer* Dialog::getAnswer(unsigned int index) const //returned sting der Antwort zur Id.
{
return nullptr;
- // return (this->answers_.find(answerId))->second.getAnswer();
}
- std::vector<std::string>* Dialog::getAnswerIds() // returned vector mit allen momentanen AntwortenIds
+
+ const std::vector<std::string>* Dialog::getAnswerIds() // returned vector mit allen momentanen AntwortenIds
{
Question* question = (this->questions_.find(this->currentQuestionId_))->second;
- std::vector<std::string>* answers = question->getAnswerIds();
+ const std::vector<std::string>* answers = question->getAnswerIds();
return answers;
}
@@ -102,27 +100,23 @@
return false;
}
- void Dialog::update(std::string givenAnswer)
+ void Dialog::update(const std::string& givenAnswerId)
{
- Answer* answer = (answers_.find(givenAnswer))->second;
+ Answer* answer = (answers_.find(givenAnswerId))->second;
this->currentQuestionId_ = answer->getNextQuestion();
}
- bool Dialog::ending() //retruned true wenn die Id der Antwort end ist oder keine Antworten auf die frage eingetragen sind
+ bool Dialog::ending(const std::string& givenAnswerId)
{
- bool end = false;
- if ((this->questions_.find(this->currentQuestionId_)->second)->getAnswerIds()->empty()){
- end = true;
- }
- return end;
+ return !this->questions_.count(this->answers_.find(givenAnswerId)->second->getNextQuestion());
}
- std::string Dialog::getQuestionString()
+ const std::string& Dialog::getQuestionString()
{
return this->questions_.find(this->currentQuestionId_)->second->getQuestion();
}
- std::string Dialog::getAnswerString(std::string answerId)
+ const std::string& Dialog::getAnswerString(std::string answerId)
{
return this->answers_.find(answerId)->second->getAnswer();
}
Modified: code/branches/Dialog_HS17/src/modules/dialog/Dialog.h
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/Dialog.h 2017-12-07 17:25:56 UTC (rev 11643)
+++ code/branches/Dialog_HS17/src/modules/dialog/Dialog.h 2017-12-08 13:55:15 UTC (rev 11644)
@@ -23,28 +23,30 @@
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 setName(const std::string& name); //xmlPort-Funktion, setzt Namen
+ const std::string& getName() const; //xmlPort-Funktion, returnt Namen
- void setCurrentQuestionId(std::string questionId);
- std::string getCurrentQuestionId();
+ void setCurrentQuestionId(const std::string& questionId); //xmlPort-Funktion, setzt string Id der momentanen Frage
+ const std::string& getCurrentQuestionId() const; //xmlPort-Funktion, gibt Id der momentanen Frage
- void addQuestion(Question* question); //fuegt Question der Map hinzu
- void addAnswer(Answer* answer); //fuegt Answer der Map hinzu
+ void addQuestion(Question* question); //xmlPort-Funktion, fuegt Question der Map hinzu
+ const Question* getQuestion() const; //xmlPort-Funktion, returnt nullptr
- Question* getQuestion(unsigned int index) const; // // benoetigt fuer xmlPort
- Answer* getAnswer(unsigned int index) const; // benoetigt fuer xmlPort
- std::vector<std::string>* getAnswerIds(); // returned vector mit allen momentanen AntwortenIds
+ void addAnswer(Answer* answer); //xmlPort-Funktion, fuegt Answer der Map hinzu
+ const Answer* getAnswer(unsigned int index) const; //xmlPort-Funktion, returnt nullptr
- bool execute(bool bTriggered, BaseObject* trigger);
- void update(std::string givenAnswer);
+ const std::vector<std::string>* getAnswerIds(); // returned Pointer auf Vector mit allen momentanen AntwortenIds
- bool ending(); //retruned true wenn die Id der Antwort end ist oder keine Antworten auf die frage eingetragen sind
+ bool execute(bool bTriggered, BaseObject* trigger); // funktion die aufgerufen wird wenn der im xml verbundene Trigger aktiviert wird
- std::string getQuestionString(); //gibt string der momentanen Frage
- std::string getAnswerString(std::string answerId); //gibt string der zur Id passenden Frage
+ void update(const std::string& givenAnswerId); //setzt die naechste Frage entsprechend der gegebenen antwortId
+ bool ending(const std::string& givenAnswerId); //ist true falls fuer die gegebene AntwortId keine Frage zur FragenId der Antwort existiert
+
+ const std::string& getQuestionString(); //gibt string der momentanen Frage
+ const std::string& getAnswerString(std::string answerId); //gibt string der zur Id passenden Frage
+
private:
std::string name_;
std::string currentQuestionId_;
Modified: code/branches/Dialog_HS17/src/modules/dialog/DialogManager.cc
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/DialogManager.cc 2017-12-07 17:25:56 UTC (rev 11643)
+++ code/branches/Dialog_HS17/src/modules/dialog/DialogManager.cc 2017-12-08 13:55:15 UTC (rev 11644)
@@ -28,7 +28,7 @@
int DialogManager::getSize()
{
- return 2; //return this->answerIds_->size();
+ return this->answerIds_->size();
}
std::string DialogManager::getAnswer(int index)
@@ -41,9 +41,17 @@
return this->currentTalk_->getName();
}
- bool DialogManager::endtest()
- {
- return this->currentTalk_->ending();
+ bool DialogManager::endtest(int index)
+ {
+ if(this->answerIds_->empty())
+ {
+ return true;
+ }
+ else
+ {
+ return this->currentTalk_->ending(this->answerIds_->at(index));
+ }
+
}
void DialogManager::update(int index)
Modified: code/branches/Dialog_HS17/src/modules/dialog/DialogManager.h
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/DialogManager.h 2017-12-07 17:25:56 UTC (rev 11643)
+++ code/branches/Dialog_HS17/src/modules/dialog/DialogManager.h 2017-12-08 13:55:15 UTC (rev 11644)
@@ -21,18 +21,30 @@
DialogManager();
-
+ //gibt lua den pointer auf den Manager
static DialogManager& getInstance() { return Singleton<DialogManager>::getInstance(); } //tolua_export
+ //setzt den momentanen Dialog auf den uebergebenen, wird vom Dialog verwendet um bei Trigger event sich selbst zu setzen
void setDialog(Dialog* dialog);
- //from here on luafunctionality is declared
+ //von hier an sind lua funktionalitaeten definiert
+ //gibt den string der momentanen Frage des Dialogs
std::string getQuestion(); //tolua_export
+
+ //gibt die laenge des Antwort-arrays der momentanen zuruek, 0 falls es leer ist
int getSize(); //tolua_export
+
+ //gibt den sting zu einer Frage im antwortarray der momentanen Frage
std::string getAnswer(int index); //tolua_export
+
+ //gibt den Namen der Person mit der man spricht
std::string getPerson(); //tolua_export
- bool endtest(); //tolua_export
+
+ //testet ob der dialog weiter geht, true wenn es keine weitere Frage nach der Antwort kommt oder keine Antwort zur Frage existiert
+ bool endtest(int index); //tolua_export
+
+ //updated den Dialog so dass er auf die Antwort die im Antwortvector am index steht reagiert
void update(int index); //tolua_export
private:
@@ -39,7 +51,7 @@
static DialogManager* singletonPtr_s;
Dialog* currentTalk_;
- std::vector<std::string>* answerIds_;
+ const std::vector<std::string>* answerIds_;
};//tolua_export
}//tolua_export
Modified: code/branches/Dialog_HS17/src/modules/dialog/Question.cc
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/Question.cc 2017-12-07 17:25:56 UTC (rev 11643)
+++ code/branches/Dialog_HS17/src/modules/dialog/Question.cc 2017-12-08 13:55:15 UTC (rev 11644)
@@ -21,22 +21,22 @@
XMLPortObject(Question, AnswerId, "answerIds", addAnswerId, getAnswerId, xmlement, mode);
}
- void Question::setQuestionId(std::string Id)
+ void Question::setQuestionId(const std::string& Id)
{
this->questionId_ = Id;
}
- std::string Question::getQuestionId()
+ const std::string& Question::getQuestionId() const
{
return this->questionId_;
}
- void Question::setQuestion(std::string question)
+ void Question::setQuestion(const std::string& question)
{
this->question_ = question;
}
- std::string Question::getQuestion()
+ const std::string& Question::getQuestion() const
{
return this->question_;
}
@@ -46,12 +46,12 @@
this->answerIds_.push_back(answerId->getId());
}
- AnswerId* Question::getAnswerId(unsigned int index) const
+ const AnswerId* Question::getAnswerId() const
{
return nullptr;
}
- std::vector<std::string>* Question::getAnswerIds()
+ const std::vector<std::string>* Question::getAnswerIds()
{
return &(this->answerIds_);
}
Modified: code/branches/Dialog_HS17/src/modules/dialog/Question.h
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/Question.h 2017-12-07 17:25:56 UTC (rev 11643)
+++ code/branches/Dialog_HS17/src/modules/dialog/Question.h 2017-12-08 13:55:15 UTC (rev 11644)
@@ -19,23 +19,19 @@
virtual void XMLPort(Element& xmelement, XMLPort::Mode mode);
- void setQuestionId(std::string Id);
- std::string getQuestionId();
+ void setQuestionId(const std::string& Id); //xmlPort-Funktion, setzt Id
+ const std::string& getQuestionId() const; //xmlPort-Funktion, gibt Id string zuruek
- void setQuestion(std::string question);
- std::string getQuestion();
+ void setQuestion(const std::string& question); //xmlPort-Funktion, setzt Fragen string
+ const std::string& getQuestion() const; //xmlPort-Funktion, gibt Fragen string
- void addAnswerId(AnswerId* answerId); //leer lassen um Dialog zu beenden
- AnswerId* getAnswerId(unsigned int index) const;
+ void addAnswerId(AnswerId* answerId); //xmlPort-Funktion, nimmt AnswerIds von entsprechenden Objekten und fuegt sie in List ein.
+ const AnswerId* getAnswerId() const; //xmlPort-Funktion, gibt nichts zuruek
-
- //braucht es getAnswerId oder reicht es andere funktion anzugeben,
- // die sowieso gebraucht wird?
+ const std::vector<std::string>* getAnswerIds(); //returnt Pointer auf Vektor mit allen Ids
- std::vector<std::string>* getAnswerIds(); //returnt vektor mit allen Ids
-
private:
std::string questionId_;
std::string question_;
More information about the Orxonox-commit
mailing list