Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11642 for code/branches


Ignore:
Timestamp:
Dec 7, 2017, 9:25:39 AM (7 years ago)
Author:
kuchlert
Message:

erste version bei der listenauswahl funktioniert

Location:
code/branches/Dialog_HS17
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • code/branches/Dialog_HS17/data/gui/layouts/Dialog.layout

    r11579 r11642  
    22
    33<GUILayout >
    4     <Window Type="DefaultWindow" Name="orxonox/Dialogue/Background" >
     4    <Window Type="DefaultWindow" Name="orxonox/Dialog/Background" >
    55        <Property Name="InheritsAlpha" Value="False" />
    66        <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
    77        <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
    8         <Window Type="MenuWidgets/StaticText" Name="orxonox/Dialogue/Inventory" >
     8        <Window Type="MenuWidgets/StaticText" Name="orxonox/Dialog/Options" >
    99            <Property Name="Alpha" Value="0.8" />
    1010            <Property Name="InheritsAlpha" Value="False" />
     
    1313            <Property Name="VertFormatting" Value="TopAligned" />
    1414            <Property Name="UnifiedAreaRect" Value="{{0.15,0},{0.15,0},{0.85,0},{0.8,0}}" />
    15             <Window Type="MenuWidgets/StaticText" Name="orxonox/Dialogue/Wrapper" >
    16                 <Property Name="TextColours" Value="FF4444FF" />
     15
     16            <Window Type="MenuWidgets/StaticText" Name="orxonox/Dialog/Person" >
     17                <Property Name="Alpha" Value="0.8" />
    1718                <Property Name="InheritsAlpha" Value="False" />
     19                <Property Name="HorzFormatting" Value="LeftAligned" />
    1820                <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
     21                <Property Name="VertFormatting" Value="CentreAligned" />
     22                <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.05,0},{0.25,0},{0.15,0}}" />
     23            </Window>
     24            <Window Type="MenuWidgets/StaticText" Name="orxonox/Dialog/Question" >
     25                <Property Name="Alpha" Value="0.8" />
     26                <Property Name="InheritsAlpha" Value="False" />
     27                <Property Name="HorzFormatting" Value="LeftAligned" />
     28                <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
     29                <Property Name="VertFormatting" Value="CentreAligned" />
     30                <Property Name="UnifiedAreaRect" Value="{{0.3,0},{0.05,0},{0.95,0},{0.15,0}}" />
     31            </Window>
     32
     33            <Window Type="MenuWidgets/StaticText" Name="orxonox/DialogAns" >
     34                <Property Name="InheritsAlpha" Value="False" />
    1935                <Property Name="HorzFormatting" Value="HorzCentred" />
     36                <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
    2037                <Property Name="VertFormatting" Value="TopAligned" />
    21                 <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.15,0},{0.95,0},{0.92,0}}" />
    22                 <Window Type="MenuWidgets/TabControl" Name="orxonox/SingleplayerTabControl" >
    23                     <Property Name="TabHeight" Value="{0,26.4388}" />
     38                <Property Name="UnifiedAreaRect" Value="{{0.604166,0},{0.15,0},{0.958333,0},{0.636,0}}" />
     39                <Window Type="MenuWidgets/Listbox" Name="orxonox/AnsListbox" >
    2440                    <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
    25                     <Property Name="TabPanePosition" Value="Top" />
    26                     <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.1,0},{0,95,0},{0.925,0}}" />
     41                    <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.225,0},{0.95,0},{0.92,0}}" />
     42                    <Event Name="ItemSelectionChanged" Function="Dialog.answer_changed" />
    2743                </Window>
     44            </Window>
     45            <Window Type="MenuWidgets/Button" Name="orxonox/SayButton" >
     46                <Property Name="Text" Value="Say" />
     47                <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
     48                <Property Name="UnifiedAreaRect" Value="{{0.425,0},{0.9,0},{0.575,0},{0.975,0}}" />
     49                <Event Name="Clicked" Function="Dialog.Button_clicked"/>
    2850            </Window>
    2951        </Window>
  • code/branches/Dialog_HS17/data/gui/scripts/Dialog.lua

    r11612 r11642  
    55P.wrapper = nil
    66P.detailsWindows = {}
    7 
    87P.showing = false
    98
     
    3231end
    3332
    34 function P.update()
    35     P.updateDialog()
    36 end
    37 
    3833function P.createDialog()
    3934
    4035    local manager = orxonox.DialogManager:getInstance()
    4136   
    42     ---[[
    43     root = winMgr:getWindow("orxonox/Dialogue/Inventory")
    44     local question = orxonox.DialogueManager:getInstance():getquestion()
    45     root:setText(question)
    46     P.wrapper = winMgr:createWindow("MenuWidgets/ScrollablePane", "orxonox/Dialogue/Inventory/Wrapper")
    47     P.wrapper:setSize(CEGUI.UVector2(CEGUI.UDim(1,0),CEGUI.UDim(1,0)))
    48     root:addChildWindow(P.wrapper)
    4937   
     38    local personfield = winMgr:getWindow("orxonox/Dialog/Person")
     39    local person = manager:getPerson()
     40    personfield:setText(person)
     41
     42    local questionfiled = winMgr:getWindow("orxonox/Dialog/Question")
     43    local question = manager:getQuestion()
     44    questionfiled:setText(question)
     45
     46    listboxwindow = winMgr:getWindow("orxonox/AnsListbox")
     47
     48    local themeList = {}
     49    --[[
     50    table.insert(themeList, "Default")
     51    table.insert(themeList, "Drum n' Bass")
     52    table.insert(themeList, "8-Bit Style")
     53    table.insert(themeList, "Corny Jazz")
     54    table.insert(themeList, "Metal")
    5055    --]]
    51     detailsButton = winMgr:createWindow("MenuWidgets/Button", "/DetailsButton")
    52     detailsButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0.1, 0),CEGUI.UDim(0.5, (P.imageHeight-P.textHeight)/2)))
    53     detailsButton:setSize(CEGUI.UVector2(CEGUI.UDim(0.25, 0), CEGUI.UDim(0, P.textHeight)))
    54     detailsButton:setText("say")
    55     orxonox.GUIManager:subscribeEventHelper(detailsButton, "Clicked", P.name ..".Button_clicked")
    56     P.wrapper:addChildWindow(detailsButton)
    57     --]]
     56    local anssize = manager:getSize()
    5857
     58    for index = 0, anssize -1, 1 do
     59        table.insert(themeList, manager:getAnswer(index))
     60    end 
     61
     62    for k,v in pairs(themeList) do
     63        item = CEGUI.createListboxTextItem(v)
     64        item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
     65        CEGUI.toListbox(listboxwindow):addItem(item)
     66    end
    5967end
    6068
    6169function P.updateDialog()
    62     --local questionn = orxonox.DialogueManager:getInstance():getquestion()
    63     --root:setText("test")
     70    local manager = orxonox.DialogManager:getInstance()
     71    --manager:update()
     72
     73    local questionfiled = winMgr:getWindow("orxonox/Dialog/Question")
     74    local question = manager:getQuestion()
     75    questionfiled:setText(question)
     76end
     77
     78function P.answer_changed(e)
     79    -- body
    6480end
    6581
     
    86102
    87103function P.Button_clicked(e)
    88     --local ending = orxonox.DialogManager:getInstance():theEnd()
     104    local ending = orxonox.DialogManager:getInstance():endtest()
     105    orxonox.CommandExecutor:execute("OrxonoxOverlay toggleVisibility Dialog")
    89106   
    90     --if ending then
     107    if ending then
    91108        orxonox.CommandExecutor:execute("OrxonoxOverlay toggleVisibility Dialog")
    92109   
    93110   
    94    -- else
    95    --     orxonox.DialogueManager:getInstance():a1clicked()
    96    --     P.update()
    97    -- end
     111    else
     112        P.updateDialog(index)
     113    end
    98114end
    99115
  • code/branches/Dialog_HS17/data/levels/DialogueShowcase2.oxw

    r11579 r11642  
    3333   
    3434    <Dialog name="Kurt" currentQuestionId="loop">
    35       <Question question="Soll ich dich loopen?" Id="loop">
    36         <AnswerId Id="ja"/>
    37         <AnswerId Id="nein"/>
    38       </Question>
    39       <Question question="Dann eben nicht" Id="ok"/>
    40       <Answer Id="ja" answer="ja loop mich" nextQuestionId="loop"/>
    41       <Answer Id="nein" answer="lieber nicht" nextQuestionId="ok"/>
     35      <questions>
     36        <Question question="Soll ich dich loopen?" Id="loop">
     37          <answerIds>
     38            <AnswerId Id="ja"/>
     39            <AnswerId Id="nein"/>
     40          </answerIds>
     41        </Question>
     42        <Question question="Dann eben nicht" Id="ok"/>
     43      </questions>
     44      <answers>
     45        <Answer Id="ja" answer="ja loop mich" nextQuestionId="loop"/>
     46        <Answer Id="nein" answer="lieber nicht" nextQuestionId="ok"/>
     47      </answers>
    4248      <events>
    4349        <execute>
  • code/branches/Dialog_HS17/src/modules/dialog/Dialog.cc

    r11612 r11642  
    2424                XMLPortParam(Dialog, "name", setName, getName, xmlelement, mode);
    2525                XMLPortParam(Dialog, "currentQuestionId", setCurrentQuestionId, getCurrentQuestionId, xmlelement, mode);
    26                 XMLPortObject(Dialog, Question, "Questions", addQuestion, getQuestion, xmlelement, mode);
    27                 XMLPortObject(Dialog, Answer, "Answers", addAnswer, getAnswer, xmlelement, mode);
     26                XMLPortObject(Dialog, Question, "questions", addQuestion, getQuestion, xmlelement, mode);
     27                XMLPortObject(Dialog, Answer, "answers", addAnswer, getAnswer, xmlelement, mode);
    2828        }
    2929
     
    7979        }
    8080
    81         std::vector<std::string> Dialog::getAnswers() // returned vector mit allen momentanen AntwortenIds
     81        std::vector<std::string>* Dialog::getAnswerIds() // returned vector mit allen momentanen AntwortenIds
    8282        {
    83 
     83               
    8484                Question* question = (this->questions_.find(this->currentQuestionId_))->second;
    85                 std::vector<std::string> answers = question->getAnswerIds();
     85                std::vector<std::string>* answers = question->getAnswerIds();
    8686                return answers;
     87               
    8788        }
    8889       
     
    9091    { 
    9192        DialogManager& m = DialogManager::getInstance();
    92         m.setDialog(this);
    93         orxout() << "dialog executed \n";
    94         OrxonoxOverlay::showOverlay("Dialog");
    95 
     93       
     94        if(questions_.count(this->currentQuestionId_)){
     95                m.setDialog(this);
     96                OrxonoxOverlay::showOverlay("Dialog");
     97        }
     98        else {
     99                orxout() << "no start defined " << endl;
     100        }
     101       
    96102        return false;
    97103    }
     
    106112    {
    107113        bool end = false;
    108         if (this->currentQuestionId_ == "end"){
    109                 end = true;
    110         } else if ((this->questions_.find(this->currentQuestionId_)->second)->getAnswerIds().empty()){
     114        if ((this->questions_.find(this->currentQuestionId_)->second)->getAnswerIds()->empty()){
    111115                end = true;
    112116        }       
     
    118122                return this->questions_.find(this->currentQuestionId_)->second->getQuestion();
    119123        }
     124
     125        std::string Dialog::getAnswerString(std::string answerId)
     126        {
     127                return this->answers_.find(answerId)->second->getAnswer();
     128        }
    120129}
  • code/branches/Dialog_HS17/src/modules/dialog/Dialog.h

    r11612 r11642  
    3535                        Question* getQuestion(unsigned int index) const; // // benoetigt fuer xmlPort
    3636                        Answer* getAnswer(unsigned int index) const; // benoetigt fuer xmlPort
    37                         std::vector<std::string> getAnswers();  // returned vector mit allen momentanen AntwortenIds
     37                        std::vector<std::string>* getAnswerIds();       // returned vector mit allen momentanen AntwortenIds
    3838
    3939                        bool execute(bool bTriggered, BaseObject* trigger);
     
    4444
    4545                        std::string getQuestionString(); //gibt string der momentanen Frage
     46                        std::string getAnswerString(std::string answerId); //gibt string der zur Id passenden Frage
    4647
    4748                private:
  • code/branches/Dialog_HS17/src/modules/dialog/DialogManager.cc

    r11612 r11642  
    1616        void DialogManager::setDialog(Dialog* dialog)
    1717        {
    18                 this->currentTalk_ = dialog;   
     18                this->currentTalk_ = dialog;
     19                answerIds_ = currentTalk_->getAnswerIds();     
    1920        }
    2021
     
    2627    }
    2728
    28     /*
    29     std::vector<std::string> DialogManager::getAnswers()
     29    int DialogManager::getSize()
     30    {   
     31        return 2; //return this->answerIds_->size();
     32    }
     33
     34    std::string DialogManager::getAnswer(int index)
    3035    {
    31         // lua hat komisch arrays (eigentlich tables), wie implementiert man answers so das man nacher den key der gegeben antwort a
    32         // hat um ihn fuer update zu benutzen?
     36        return this->currentTalk_->getAnswerString(this->answerIds_->at(index));
    3337    }
    34         */
     38       
     39    std::string DialogManager::getPerson()
     40    {
     41        return this->currentTalk_->getName();
     42    }
     43
     44    bool DialogManager::endtest()
     45    {
     46        return this->currentTalk_->ending();
     47    }
     48
     49    void DialogManager::update(int index)
     50    {
     51        this->currentTalk_->update(answerIds_->at(index));
     52        answerIds_ = this->currentTalk_->getAnswerIds();
     53    }
    3554}
  • code/branches/Dialog_HS17/src/modules/dialog/DialogManager.h

    r11612 r11642  
    3030
    3131        std::string getQuestion(); //tolua_export
    32         //std::vector<std::string> getAnswers();
     32        int getSize(); //tolua_export
     33        std::string getAnswer(int index); //tolua_export
     34        std::string getPerson(); //tolua_export
     35        bool endtest(); //tolua_export
     36        void update(int index); //tolua_export
    3337
    3438private:
     
    3640
    3741    Dialog* currentTalk_;
     42    std::vector<std::string>* answerIds_;
    3843
    3944    };//tolua_export
  • code/branches/Dialog_HS17/src/modules/dialog/Question.cc

    r11611 r11642  
    1919                XMLPortParam(Question, "Id", setQuestionId, getQuestionId, xmlement, mode);
    2020
    21                 XMLPortObject(Question, AnswerId, "answers", addAnswerId, getAnswerId, xmlement, mode);
     21                XMLPortObject(Question, AnswerId, "answerIds", addAnswerId, getAnswerId, xmlement, mode);
    2222        }
    2323
     
    5252        }
    5353
    54         std::vector<std::string> Question::getAnswerIds()
     54        std::vector<std::string>* Question::getAnswerIds()
    5555        {
    56                 return this->answerIds_;
     56                return &(this->answerIds_);
    5757        }
    5858       
  • code/branches/Dialog_HS17/src/modules/dialog/Question.h

    r11611 r11642  
    3333                        // die sowieso gebraucht wird?
    3434
    35                         std::vector<std::string> getAnswerIds(); //returnt vektor mit allen Ids
     35                        std::vector<std::string>* getAnswerIds(); //returnt vektor mit allen Ids
    3636
    3737
Note: See TracChangeset for help on using the changeset viewer.