1 /*
2  *  This file is part of Dune Legacy.
3  *
4  *  Dune Legacy is free software: you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation, either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  Dune Legacy is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with Dune Legacy.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef MENTATMENU_H
19 #define MENTATMENU_H
20 
21 #include "MenuBase.h"
22 #include <GUI/StaticContainer.h>
23 #include <GUI/Button.h>
24 #include <GUI/dune/AnimationLabel.h>
25 #include <GUI/Label.h>
26 
27 #include <misc/string_util.h>
28 
29 #include <stdio.h>
30 
31 #include <SDL.h>
32 #include <string>
33 
34 class MentatMenu : public MenuBase {
35 public:
36     explicit MentatMenu(int newHouse);
37     virtual ~MentatMenu();
38 
39     virtual void drawSpecificStuff();
40 
41     virtual void update();
42 
doInput(SDL_Event & event)43     virtual bool doInput(SDL_Event &event) {
44         if(event.type == SDL_MOUSEBUTTONDOWN) {
45             showNextMentatText();
46         }
47 
48         return MenuBase::doInput(event);
49     }
50 
setText(const std::string & text)51     void setText(const std::string& text) {
52         mentatTexts = splitString(text, ". ", true);
53 
54         mouthAnim.getAnimation()->setNumLoops(mentatTexts[0].empty() ? 0 : mentatTexts[0].length()/25 + 1);
55         textLabel.setText(mentatTexts[0]);
56         textLabel.setVisible(true);
57         textLabel.resize(620,240);
58 
59         currentMentatTextIndex = 0;
60         nextMentatTextSwitch = SDL_GetTicks() + mentatTexts[0].length() * 75 + 1000;
61     }
62 
showNextMentatText()63     void showNextMentatText() {
64         nextMentatTextSwitch = 0;
65     }
66 
onMentatTextFinished()67     virtual void onMentatTextFinished() { }
68 
69     int getMissionSpecificAnim(int missionnumber) const;
70 
71 protected:
72     enum MentatEyes {
73         MentatEyesNormal = 0,
74         MentatEyesLeft = 1,
75         MentatEyesRight = 2,
76         MentatEyesDown = 3,
77         MentatEyesClosed = 4
78     };
79 
80 
81     enum MentatMouth {
82         MentatMouthClosed = 0,
83         MentatMouthOpen1 = 1,
84         MentatMouthOpen2 = 2,
85         MentatMouthOpen3 = 3,
86         MentatMouthOpen4 = 4
87     };
88 
89     Uint32  nextSpecialAnimation;
90 
91     std::vector<std::string> mentatTexts;
92     int currentMentatTextIndex;
93     Uint32 nextMentatTextSwitch;
94     int house;
95 
96     StaticContainer windowWidget;
97     AnimationLabel  eyesAnim;
98     AnimationLabel  mouthAnim;
99     AnimationLabel  specialAnim;
100     AnimationLabel  shoulderAnim;
101     Label           textLabel;
102 
103 };
104 
105 #endif // MENTATMENU_H
106