ScummVM API documentation
PersonHandler.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 /*
23  * This code is based on the CRAB engine
24  *
25  * Copyright (c) Arvind Raja Yadav
26  *
27  * Licensed under MIT
28  *
29  */
30 
31 #ifndef CRAB_PERSONHANDLER_H
32 #define CRAB_PERSONHANDLER_H
33 
34 #include "crab/event/gameevent.h"
35 #include "crab/event/GameEventInfo.h"
36 #include "crab/ui/ProgressBar.h"
37 #include "crab/ui/dialogbox.h"
38 #include "crab/TTSHandler.h"
39 
40 namespace Crab {
41 
42 namespace pyrodactyl {
43 namespace anim {
44 class Sprite;
45 } // End of namespace Sprite
46 
47 namespace ui {
48 class PersonHandler : public TTSHandler {
49  // The positions of various elements
50  // img = player image position
51  Element _img;
52 
53  // How the individual sprite clips are drawn
54  struct ImageAnchor {
55  Align _x, _y;
56 
57  ImageAnchor() {
58  _x = ALIGN_CENTER;
59  _y = ALIGN_RIGHT;
60  }
61 
62  void load(rapidxml::xml_node<char> *node, const bool &echo = true) {
63  loadAlign(_x, node, echo, "align_x");
64  loadAlign(_y, node, echo, "align_y");
65  }
66  } _spriteAlign;
67 
68  // For drawing the name
69  TextData _name;
70 
71  // The dialog box used to draw dialog
73 
74  // The three opinion bars
75  pyrodactyl::ui::ProgressBar _opinion[pyrodactyl::people::OPI_TOTAL];
76 
77  // The button for selecting the journal
78  Button _jb;
79 
80  // The person id of the changed opinion, we use this to reset bar
81  Common::String _prev;
82 
83 public:
84  // Used by other objects to see if journal needs to be displayed or not
85  bool _showJournal;
86 
87  PersonHandler() {
88  _showJournal = false;
89  }
90 
91  ~PersonHandler() {}
92 
93  void reset(const Common::String &id);
94 
95  void load(rapidxml::xml_node<char> *node);
96 
97  // Handle events for the three opinion bars and journal - used in both dialog box and reply events
98  bool handleCommonEvents(const Common::Event &event);
99 
100  // Handle events for the dialog box
101  bool handleDlboxEvents(const Common::Event &event);
102 
103  void internalEvents(const pyrodactyl::people::PersonState &state, pyrodactyl::anim::Sprite *s);
104 
105  void draw(pyrodactyl::event::Info &info, pyrodactyl::event::GameEvent *event, const Common::String &personId,
106  const bool &player, pyrodactyl::anim::Sprite *s = nullptr);
107 
108  void opinionChange(pyrodactyl::event::Info &info, const Common::String &id,
109  const pyrodactyl::people::OpinionType &type, const int &val);
110 
111  void setUI();
112 };
113 } // End of namespace ui
114 } // End of namespace pyrodactyl
115 
116 } // End of namespace Crab
117 
118 #endif // CRAB_PERSONHANDLER_H
Definition: sprite.h:49
Definition: str.h:59
Definition: gameevent.h:58
Definition: GameEventInfo.h:44
Definition: element.h:42
Definition: TTSHandler.h:28
Definition: TextData.h:41
Definition: events.h:199
Definition: moveeffect.h:37
Definition: button.h:86
Definition: ProgressBar.h:41
Definition: dialogbox.h:46
Definition: PersonHandler.h:48