1 #ifndef SPEECH_DIALOG_HPP_INCLUDED 2 #define SPEECH_DIALOG_HPP_INCLUDED 3 4 #include <boost/shared_ptr.hpp> 5 6 #include "graphics.hpp" 7 8 #include <string> 9 #include <vector> 10 11 #include "color_utils.hpp" 12 #include "entity.hpp" 13 #include "gui_section.hpp" 14 15 class speech_dialog 16 { 17 public: 18 19 speech_dialog(); 20 ~speech_dialog(); 21 22 bool detect_joystick_press(); 23 bool key_press(const SDL_Event& e); 24 bool process(); 25 void draw() const; 26 void set_speaker_and_flip_side(const_entity_ptr e); 27 void set_speaker(const_entity_ptr e, bool left_side=false); 28 void set_side(bool left_side); 29 void set_text(const std::vector<std::string>& text); 30 void set_options(const std::vector<std::string>& options); set_expiration(int time)31 void set_expiration(int time) { expiration_ = time; } 32 option_selected() const33 int option_selected() const { return option_selected_; } set_option_selected(int n)34 void set_option_selected(int n) { option_selected_ = n; } 35 private: 36 bool handle_mouse_move(int x, int y); 37 void move_up(); 38 void move_down(); 39 40 bool scroll_text(); 41 42 int cycle_; 43 const_entity_ptr left_, right_; 44 bool left_side_speaking_; 45 int horizontal_position_; 46 47 struct TextMarkup { 48 int begin; 49 boost::shared_ptr<graphics::color> color; 50 }; 51 52 std::vector<std::vector<TextMarkup> > markup_; 53 54 std::vector<std::string> text_; 55 int text_char_; 56 57 std::vector<std::string> options_; 58 int option_selected_; 59 int option_width_; 60 61 bool joystick_button_pressed_, joystick_up_pressed_, joystick_down_pressed_; 62 63 int expiration_; 64 65 mutable rect pane_area_; 66 67 int num_chars() const; 68 69 speech_dialog(const speech_dialog&); 70 void operator=(const speech_dialog&); 71 }; 72 73 #endif 74