[Orxonox-commit 7023] r11642 - in code/branches/Dialog_HS17: data/gui/layouts data/gui/scripts data/levels src/modules/dialog

kuchlert at orxonox.net kuchlert at orxonox.net
Thu Dec 7 09:25:39 CET 2017


Author: kuchlert
Date: 2017-12-07 09:25:39 +0100 (Thu, 07 Dec 2017)
New Revision: 11642

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/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:
erste version bei der listenauswahl funktioniert

Modified: code/branches/Dialog_HS17/data/gui/layouts/Dialog.layout
===================================================================
--- code/branches/Dialog_HS17/data/gui/layouts/Dialog.layout	2017-12-04 17:36:34 UTC (rev 11641)
+++ code/branches/Dialog_HS17/data/gui/layouts/Dialog.layout	2017-12-07 08:25:39 UTC (rev 11642)
@@ -1,11 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
 <GUILayout >
-    <Window Type="DefaultWindow" Name="orxonox/Dialogue/Background" > 
+    <Window Type="DefaultWindow" Name="orxonox/Dialog/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" >
+        <Window Type="MenuWidgets/StaticText" Name="orxonox/Dialog/Options" >
             <Property Name="Alpha" Value="0.8" />
             <Property Name="InheritsAlpha" Value="False" />
             <Property Name="HorzFormatting" Value="HorzCentred" />
@@ -12,20 +12,42 @@
             <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" />
+
+            <Window Type="MenuWidgets/StaticText" Name="orxonox/Dialog/Person" >
+                <Property Name="Alpha" Value="0.8" />
                 <Property Name="InheritsAlpha" Value="False" />
+                <Property Name="HorzFormatting" Value="LeftAligned" />
                 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+                <Property Name="VertFormatting" Value="CentreAligned" />
+                <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.05,0},{0.25,0},{0.15,0}}" />
+            </Window>
+            <Window Type="MenuWidgets/StaticText" Name="orxonox/Dialog/Question" >
+                <Property Name="Alpha" Value="0.8" />
+                <Property Name="InheritsAlpha" Value="False" />
+                <Property Name="HorzFormatting" Value="LeftAligned" />
+                <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+                <Property Name="VertFormatting" Value="CentreAligned" />
+                <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" />
+                <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
                 <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="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="TabPanePosition" Value="Top" />
-                    <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.1,0},{0,95,0},{0.925,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>
             </Window>
+            <Window Type="MenuWidgets/Button" Name="orxonox/SayButton" >
+                <Property Name="Text" Value="Say" />
+                <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+                <Property Name="UnifiedAreaRect" Value="{{0.425,0},{0.9,0},{0.575,0},{0.975,0}}" />
+                <Event Name="Clicked" Function="Dialog.Button_clicked"/>
+            </Window>
         </Window>
          
     </Window>

Modified: code/branches/Dialog_HS17/data/gui/scripts/Dialog.lua
===================================================================
--- code/branches/Dialog_HS17/data/gui/scripts/Dialog.lua	2017-12-04 17:36:34 UTC (rev 11641)
+++ code/branches/Dialog_HS17/data/gui/scripts/Dialog.lua	2017-12-07 08:25:39 UTC (rev 11642)
@@ -4,7 +4,6 @@
 
 P.wrapper = nil
 P.detailsWindows = {}
-
 P.showing = false
 
 -- Design parameters
@@ -31,39 +30,56 @@
     P.cleanup(true)
 end
 
-function P.update()
-    P.updateDialog()
-end
-
 function P.createDialog()
 
     local manager = orxonox.DialogManager:getInstance()
     
-    ---[[
-    root = winMgr:getWindow("orxonox/Dialogue/Inventory")
-    local question = orxonox.DialogueManager:getInstance():getquestion()
-    root:setText(question)
-    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)
     
+    local personfield = winMgr:getWindow("orxonox/Dialog/Person")
+    local person = manager:getPerson()
+    personfield:setText(person)
+
+    local questionfiled = winMgr:getWindow("orxonox/Dialog/Question")
+    local question = manager:getQuestion()
+    questionfiled:setText(question)
+
+    listboxwindow = winMgr:getWindow("orxonox/AnsListbox")
+
+    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")
     --]]
-    detailsButton = winMgr:createWindow("MenuWidgets/Button", "/DetailsButton")
-    detailsButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0.1, 0),CEGUI.UDim(0.5, (P.imageHeight-P.textHeight)/2)))
-    detailsButton:setSize(CEGUI.UVector2(CEGUI.UDim(0.25, 0), CEGUI.UDim(0, P.textHeight)))
-    detailsButton:setText("say")
-    orxonox.GUIManager:subscribeEventHelper(detailsButton, "Clicked", P.name ..".Button_clicked")
-    P.wrapper:addChildWindow(detailsButton)
-    --]]
+    local anssize = manager:getSize()
 
+    for index = 0, anssize -1, 1 do
+        table.insert(themeList, manager:getAnswer(index))
+    end  
+
+    for k,v in pairs(themeList) do
+        item = CEGUI.createListboxTextItem(v)
+        item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
+        CEGUI.toListbox(listboxwindow):addItem(item)
+    end
 end
 
 function P.updateDialog()
-    --local questionn = orxonox.DialogueManager:getInstance():getquestion()
-    --root:setText("test")
+    local manager = orxonox.DialogManager:getInstance()
+    --manager:update()
+
+    local questionfiled = winMgr:getWindow("orxonox/Dialog/Question")
+    local question = manager:getQuestion()
+    questionfiled:setText(question)
 end
 
+function P.answer_changed(e)
+    -- body
+end
 
+
 function P.cleanup(destroyDetails)
     
     if P.wrapper ~= nil then
@@ -85,16 +101,16 @@
 
 
 function P.Button_clicked(e)
-    --local ending = orxonox.DialogManager:getInstance():theEnd()
+    local ending = orxonox.DialogManager:getInstance():endtest()
+    orxonox.CommandExecutor:execute("OrxonoxOverlay toggleVisibility Dialog")
     
-    --if ending then
+    if ending then
         orxonox.CommandExecutor:execute("OrxonoxOverlay toggleVisibility Dialog")
     
     
-   -- else 
-   --     orxonox.DialogueManager:getInstance():a1clicked()
-   --     P.update()
-   -- end
+    else 
+        P.updateDialog(index)
+    end
 end
 
 return P

Modified: code/branches/Dialog_HS17/data/levels/DialogueShowcase2.oxw
===================================================================
--- code/branches/Dialog_HS17/data/levels/DialogueShowcase2.oxw	2017-12-04 17:36:34 UTC (rev 11641)
+++ code/branches/Dialog_HS17/data/levels/DialogueShowcase2.oxw	2017-12-07 08:25:39 UTC (rev 11642)
@@ -32,13 +32,19 @@
     <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"/>
+      <questions>
+        <Question question="Soll ich dich loopen?" Id="loop">
+          <answerIds>
+            <AnswerId Id="ja"/>
+            <AnswerId Id="nein"/>
+          </answerIds>
+        </Question>
+        <Question question="Dann eben nicht" Id="ok"/>
+      </questions>
+      <answers>
+        <Answer Id="ja" answer="ja loop mich" nextQuestionId="loop"/>
+        <Answer Id="nein" answer="lieber nicht" nextQuestionId="ok"/>
+      </answers>
       <events>
         <execute>
           <EventListener event="test"/>

Modified: code/branches/Dialog_HS17/src/modules/dialog/Dialog.cc
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/Dialog.cc	2017-12-04 17:36:34 UTC (rev 11641)
+++ code/branches/Dialog_HS17/src/modules/dialog/Dialog.cc	2017-12-07 08:25:39 UTC (rev 11642)
@@ -23,8 +23,8 @@
 
 		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);
+		XMLPortObject(Dialog, Question, "questions", addQuestion, getQuestion, xmlelement, mode);
+		XMLPortObject(Dialog, Answer, "answers", addAnswer, getAnswer, xmlelement, mode);
 	}
 
 	void Dialog::XMLEventPort(Element& xmlelement, XMLPort::Mode mode)
@@ -78,21 +78,27 @@
 		// return (this->answers_.find(answerId))->second.getAnswer();
 	}
 
-	std::vector<std::string> Dialog::getAnswers() // returned vector mit allen momentanen AntwortenIds
+	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();
+		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");
-
+    	
+    	if(questions_.count(this->currentQuestionId_)){
+    		m.setDialog(this);
+    		OrxonoxOverlay::showOverlay("Dialog");
+    	}
+    	else {
+    		orxout() << "no start defined " << endl;
+    	}
+    	
         return false;
     }
 
@@ -105,10 +111,8 @@
     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"){
+    	if ((this->questions_.find(this->currentQuestionId_)->second)->getAnswerIds()->empty()){
     		end = true;
-    	} else if ((this->questions_.find(this->currentQuestionId_)->second)->getAnswerIds().empty()){
-    		end = true;
     	}	
     	return end;
     }
@@ -117,4 +121,9 @@
 	{
 		return this->questions_.find(this->currentQuestionId_)->second->getQuestion();
 	}
+
+	std::string Dialog::getAnswerString(std::string answerId)
+	{
+		return this->answers_.find(answerId)->second->getAnswer();
+	}
 }
\ No newline at end of file

Modified: code/branches/Dialog_HS17/src/modules/dialog/Dialog.h
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/Dialog.h	2017-12-04 17:36:34 UTC (rev 11641)
+++ code/branches/Dialog_HS17/src/modules/dialog/Dialog.h	2017-12-07 08:25:39 UTC (rev 11642)
@@ -34,7 +34,7 @@
 
 			Question* getQuestion(unsigned int index) const; // // benoetigt fuer xmlPort
 			Answer* getAnswer(unsigned int index) const; // benoetigt fuer xmlPort
-			std::vector<std::string> getAnswers(); 	// returned vector mit allen momentanen AntwortenIds
+			std::vector<std::string>* getAnswerIds(); 	// returned vector mit allen momentanen AntwortenIds
 
 	 		bool execute(bool bTriggered, BaseObject* trigger);
 
@@ -43,6 +43,7 @@
 			bool ending(); //retruned true wenn die Id der Antwort end ist oder keine Antworten auf die frage eingetragen sind
 
 			std::string getQuestionString(); //gibt string der momentanen Frage 
+			std::string getAnswerString(std::string answerId); //gibt string der zur Id passenden Frage
 
 		private: 
 			std::string name_;

Modified: code/branches/Dialog_HS17/src/modules/dialog/DialogManager.cc
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/DialogManager.cc	2017-12-04 17:36:34 UTC (rev 11641)
+++ code/branches/Dialog_HS17/src/modules/dialog/DialogManager.cc	2017-12-07 08:25:39 UTC (rev 11642)
@@ -15,7 +15,8 @@
 
 	void DialogManager::setDialog(Dialog* dialog)
 	{
-		this->currentTalk_ = dialog;	
+		this->currentTalk_ = dialog;
+		answerIds_ = currentTalk_->getAnswerIds();	
 	}
 
 	//from here onward funcionality for lua axports
@@ -25,11 +26,29 @@
     	return this->currentTalk_->getQuestionString();
     }
 
-    /*
-    std::vector<std::string> DialogManager::getAnswers()
+    int DialogManager::getSize()
+    {   
+        return 2; //return this->answerIds_->size();
+    }
+
+    std::string DialogManager::getAnswer(int index)
     {
-    	// lua hat komisch arrays (eigentlich tables), wie implementiert man answers so das man nacher den key der gegeben antwort a
-    	// hat um ihn fuer update zu benutzen?
+    	return this->currentTalk_->getAnswerString(this->answerIds_->at(index));
     }
-	*/
+	
+    std::string DialogManager::getPerson()
+    {
+    	return this->currentTalk_->getName();
+    }
+
+    bool DialogManager::endtest()
+    {
+    	return this->currentTalk_->ending();
+    }
+
+    void DialogManager::update(int index)
+    {
+    	this->currentTalk_->update(answerIds_->at(index));
+    	answerIds_ = this->currentTalk_->getAnswerIds();
+    }
 }

Modified: code/branches/Dialog_HS17/src/modules/dialog/DialogManager.h
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/DialogManager.h	2017-12-04 17:36:34 UTC (rev 11641)
+++ code/branches/Dialog_HS17/src/modules/dialog/DialogManager.h	2017-12-07 08:25:39 UTC (rev 11642)
@@ -29,12 +29,17 @@
         //from here on luafunctionality is declared
 
         std::string getQuestion(); //tolua_export
-        //std::vector<std::string> getAnswers();
+        int getSize(); //tolua_export
+        std::string getAnswer(int index); //tolua_export
+        std::string getPerson(); //tolua_export
+        bool endtest(); //tolua_export
+        void update(int index); //tolua_export
 
 private:
     static DialogManager* singletonPtr_s;
 
     Dialog* currentTalk_;
+    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-04 17:36:34 UTC (rev 11641)
+++ code/branches/Dialog_HS17/src/modules/dialog/Question.cc	2017-12-07 08:25:39 UTC (rev 11642)
@@ -18,7 +18,7 @@
 		XMLPortParam(Question, "question", setQuestion, getQuestion, xmlement, mode);
 		XMLPortParam(Question, "Id", setQuestionId, getQuestionId, xmlement, mode);
 
-		XMLPortObject(Question, AnswerId, "answers", addAnswerId, getAnswerId, xmlement, mode);
+		XMLPortObject(Question, AnswerId, "answerIds", addAnswerId, getAnswerId, xmlement, mode);
 	}
 
 	void Question::setQuestionId(std::string Id)
@@ -51,9 +51,9 @@
 		return nullptr;
 	}
 
-	std::vector<std::string> Question::getAnswerIds()
+	std::vector<std::string>* Question::getAnswerIds()
 	{
-		return this->answerIds_;
+		return &(this->answerIds_);
 	}
 	
 }
\ No newline at end of file

Modified: code/branches/Dialog_HS17/src/modules/dialog/Question.h
===================================================================
--- code/branches/Dialog_HS17/src/modules/dialog/Question.h	2017-12-04 17:36:34 UTC (rev 11641)
+++ code/branches/Dialog_HS17/src/modules/dialog/Question.h	2017-12-07 08:25:39 UTC (rev 11642)
@@ -32,7 +32,7 @@
 			//braucht es getAnswerId oder reicht es andere funktion anzugeben,
 			// die sowieso gebraucht wird?
 
-			std::vector<std::string> getAnswerIds(); //returnt vektor mit allen Ids
+			std::vector<std::string>* getAnswerIds(); //returnt vektor mit allen Ids
 
 
 



More information about the Orxonox-commit mailing list